/** * {@inheritDoc} */ public boolean isMultiple() { return ((QPropertyDefinition) itemDef).isMultiple(); }
/** * {@inheritDoc} */ public boolean isMultiple() { return ((QPropertyDefinition) itemDef).isMultiple(); }
public boolean isMultiValued() { return definition.isMultiple(); }
public boolean isMultiValued() { return definition.isMultiple(); }
/** * Create a NEW PropertyState * * @param entry * @param isf * @param definition * @param definitionProvider */ protected PropertyState(PropertyEntry entry, ItemStateFactory isf, QPropertyDefinition definition, ItemDefinitionProvider definitionProvider, QValue[] values, int propertyType) throws ConstraintViolationException, RepositoryException { super(Status.NEW, entry, isf, definitionProvider); this.multiValued = definition.isMultiple(); this.definition = definition; setValues(values, propertyType); }
/** * Create a NEW PropertyState * * @param entry * @param isf * @param definition * @param definitionProvider */ protected PropertyState(PropertyEntry entry, ItemStateFactory isf, QPropertyDefinition definition, ItemDefinitionProvider definitionProvider, QValue[] values, int propertyType) throws ConstraintViolationException, RepositoryException { super(Status.NEW, entry, isf, definitionProvider); this.multiValued = definition.isMultiple(); this.definition = definition; setValues(values, propertyType); }
private QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type, boolean multiValued) { QPropertyDefinition match = null; for (QPropertyDefinition pd : defs) { int reqType = pd.getRequiredType(); // match type if (reqType == PropertyType.UNDEFINED || type == PropertyType.UNDEFINED || reqType == type) { // match multiValued flag if (multiValued == pd.isMultiple()) { // found match if (pd.getRequiredType() != PropertyType.UNDEFINED) { // found best possible match, get outta here return pd; } else { if (match == null) { match = pd; } } } } } return match; }
private QPropertyDefinition getMatchingPropDef(QPropertyDefinition[] defs, int type, boolean multiValued) { QPropertyDefinition match = null; for (QPropertyDefinition pd : defs) { int reqType = pd.getRequiredType(); // match type if (reqType == PropertyType.UNDEFINED || type == PropertyType.UNDEFINED || reqType == type) { // match multiValued flag if (multiValued == pd.isMultiple()) { // found match if (pd.getRequiredType() != PropertyType.UNDEFINED) { // found best possible match, get outta here return pd; } else { if (match == null) { match = pd; } } } } } return match; }
/** * Compares two property definitions for equality. Returns <code>true</code> * if the given object is a property definition and has the same attributes * as this property definition. * * @param obj the object to compare this property definition with * @return <code>true</code> if the object is equal to this property definition, * <code>false</code> otherwise * @see Object#equals(Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof QPropertyDefinition) { QPropertyDefinition other = (QPropertyDefinition) obj; return super.equals(obj) && requiredType == other.getRequiredType() && multiple == other.isMultiple() && fullTextSearchable == other.isFullTextSearchable() && queryOrderable == other.isQueryOrderable() && ((valueConstraints == null || other.getValueConstraints() == null) ? (valueConstraints == other.getValueConstraints()) : new HashSet(Arrays.asList(valueConstraints)).equals(new HashSet(Arrays.asList(other.getValueConstraints())))) && ((defaultValues == null || other.getDefaultValues() == null) ? (defaultValues == other.getDefaultValues()) : new HashSet(Arrays.asList(defaultValues)).equals(new HashSet(Arrays.asList(other.getDefaultValues())))) && new HashSet(Arrays.asList(availableQueryOperators)).equals(new HashSet(Arrays.asList(other.getAvailableQueryOperators()))); } return false; }
/** * Compares two property definitions for equality. Returns <code>true</code> * if the given object is a property defintion and has the same attributes * as this property definition. * * @param obj the object to compare this property definition with * @return <code>true</code> if the object is equal to this property definition, * <code>false</code> otherwise * @see Object#equals(Object) */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof QPropertyDefinition) { QPropertyDefinition other = (QPropertyDefinition) obj; return super.equals(obj) && requiredType == other.getRequiredType() && Arrays.equals(valueConstraints, other.getValueConstraints()) && Arrays.equals(defaultValues, other.getDefaultValues()) && multiple == other.isMultiple(); } return false; }
public void nodeTypeRegistered(Name ntName) { try { QNodeTypeDefinition def = registry.getNodeTypeDef(ntName); QPropertyDefinition[] propDefs = def.getPropertyDefs(); synchronized (typeMapping) { for (QPropertyDefinition propDef : propDefs) { int type = propDef.getRequiredType(); if (!propDef.definesResidual() && type != PropertyType.UNDEFINED) { Name name = propDef.getName(); // only remember defined property types TypeMapping[] types = typeMapping.get(name); if (types == null) { types = new TypeMapping[1]; } else { TypeMapping[] tmp = new TypeMapping[types.length + 1]; System.arraycopy(types, 0, tmp, 0, types.length); types = tmp; } types[types.length - 1] = new TypeMapping(ntName, type, propDef.isMultiple()); typeMapping.put(name, types); } } } } catch (NoSuchNodeTypeException e) { log.error("Unable to get newly registered node type definition for name: " + ntName); } }
/** Test for the <code>multiple</code> property definition attribute. */ public void testMultipleProperty() { QPropertyDefinition def = getPropDef("propertyNodeType", "multipleProperty"); assertEquals("multipleProperty multiple", true, def.isMultiple()); }
/** * Computes the auto generated values and falls back to the default values * specified in the property definition * @param state parent state * @param def property definition * @param useDefaultValues if <code>true</code> the default values are respected * @return the values or <code>null</code> * @throws RepositoryException if the values cannot be computed. */ private InternalValue[] computeAutoValues(NodeStateEx state, QPropertyDefinition def, boolean useDefaultValues) throws RepositoryException { // compute system generated values if necessary InternalValue[] values = new NodeTypeInstanceHandler(session.getUserID()). computeSystemGeneratedPropertyValues(state.getState(), def); if (values == null && useDefaultValues) { values = InternalValue.create(def.getDefaultValues()); } // avoid empty value array for single value property if (values != null && values.length == 0 && !def.isMultiple()) { values = null; } return values; } }
/** * Computes the auto generated values and falls back to the default values * specified in the property definition * @param state parent state * @param def property definition * @param useDefaultValues if <code>true</code> the default values are respected * @return the values or <code>null</code> * @throws RepositoryException if the values cannot be computed. */ private InternalValue[] computeAutoValues(NodeStateEx state, QPropertyDefinition def, boolean useDefaultValues) throws RepositoryException { // compute system generated values if necessary InternalValue[] values = new NodeTypeInstanceHandler(session.getUserID()). computeSystemGeneratedPropertyValues(state.getState(), def); if (values == null && useDefaultValues) { values = InternalValue.create(def.getDefaultValues()); } // avoid empty value array for single value property if (values != null && values.length == 0 && !def.isMultiple()) { values = null; } return values; } }
/** * Copy constructor. * * @param propDef some other property definition. */ public QPropertyDefinitionImpl(QPropertyDefinition propDef) { this(propDef.getName(), propDef.getDeclaringNodeType(), propDef.isAutoCreated(), propDef.isMandatory(), propDef.getOnParentVersion(), propDef.isProtected(), propDef.getDefaultValues(), propDef.isMultiple(), propDef.getRequiredType(), propDef.getValueConstraints()); }
/** * Copy constructor. * * @param propDef some other property definition. */ public QPropertyDefinitionImpl(QPropertyDefinition propDef) { this(propDef.getName(), propDef.getDeclaringNodeType(), propDef.isAutoCreated(), propDef.isMandatory(), propDef.getOnParentVersion(), propDef.isProtected(), propDef.getDefaultValues(), propDef.isMultiple(), propDef.getRequiredType(), propDef.getValueConstraints(), propDef.getAvailableQueryOperators(), propDef.isFullTextSearchable(), propDef.isQueryOrderable()); }
/** * Copy constructor. * * @param propDef some other property definition. */ public QPropertyDefinitionImpl(QPropertyDefinition propDef) { this(propDef.getName(), propDef.getDeclaringNodeType(), propDef.isAutoCreated(), propDef.isMandatory(), propDef.getOnParentVersion(), propDef.isProtected(), propDef.getDefaultValues(), propDef.isMultiple(), propDef.getRequiredType(), propDef.getValueConstraints(), propDef.getAvailableQueryOperators(), propDef.isFullTextSearchable(), propDef.isQueryOrderable()); }
/** Test for the empty property definition. */ public void testEmptyProperty() { QPropertyDefinition def = getPropDef("propertyNodeType", "emptyProperty"); assertEquals("emptyProperty requiredType", PropertyType.UNDEFINED, def.getRequiredType()); assertEquals("emptyProperty multiple", false, def.isMultiple()); assertNull("emptyProperty defaultValues", def.getDefaultValues()); assertEquals("emptyProperty valueConstraints", 0, def.getValueConstraints().length); }
/** * Create a new JCR property definition from the given <code>QPropertyDefinition</code>. * * @param qPd A SPI property definition. * @return the corresponding JCR property definition. * @throws RepositoryException if an error occurs. */ public PropertyDefinition create(QPropertyDefinition qPd) throws RepositoryException { PropertyDefinitionTemplate pt = ntMgr.createPropertyDefinitionTemplate(); pt.setName(getJCRName(qPd.getName())); pt.setAutoCreated(qPd.isAutoCreated()); pt.setMandatory(qPd.isMandatory()); pt.setOnParentVersion(qPd.getOnParentVersion()); pt.setProtected(qPd.isProtected()); pt.setRequiredType(qPd.getRequiredType()); pt.setMultiple(qPd.isMultiple()); pt.setFullTextSearchable(qPd.isFullTextSearchable()); pt.setValueConstraints(createValueConstraints(qPd.getRequiredType(), qPd.getValueConstraints())); pt.setAvailableQueryOperators(qPd.getAvailableQueryOperators()); pt.setQueryOrderable(qPd.isQueryOrderable()); pt.setDefaultValues(createValues(qPd.getDefaultValues())); return pt; }
/** * Create a new JCR property definition from the given <code>QPropertyDefinition</code>. * * @param qPd A SPI property definition. * @return the corresponding JCR property definition. * @throws RepositoryException if an error occurs. */ public PropertyDefinition create(QPropertyDefinition qPd) throws RepositoryException { PropertyDefinitionTemplate pt = ntMgr.createPropertyDefinitionTemplate(); pt.setName(getJCRName(qPd.getName())); pt.setAutoCreated(qPd.isAutoCreated()); pt.setMandatory(qPd.isMandatory()); pt.setOnParentVersion(qPd.getOnParentVersion()); pt.setProtected(qPd.isProtected()); pt.setRequiredType(qPd.getRequiredType()); pt.setMultiple(qPd.isMultiple()); pt.setFullTextSearchable(qPd.isFullTextSearchable()); pt.setValueConstraints(createValueConstraints(qPd.getRequiredType(), qPd.getValueConstraints())); pt.setAvailableQueryOperators(qPd.getAvailableQueryOperators()); pt.setQueryOrderable(qPd.isQueryOrderable()); pt.setDefaultValues(createValues(qPd.getDefaultValues())); return pt; }