public int getTargetType(PropertyDefinition def) { int target = def.getRequiredType(); if (target != PropertyType.UNDEFINED) { return target; } else if (type != PropertyType.UNDEFINED) { return type; } else { return PropertyType.STRING; } }
public int getTargetType(PropertyDefinition def) { int target = def.getRequiredType(); if (target != PropertyType.UNDEFINED) { return target; } else if (type != PropertyType.UNDEFINED) { return type; } else { return PropertyType.STRING; } }
/** {@inheritDoc} */ public int getRequiredType() throws RemoteException { return def.getRequiredType(); }
/** * Check if a property definition is a reference property * @param node the given node * @param propertyName the property name * @return whether a property definition is a reference property * @throws RepositoryException if repository exception occurred */ public static boolean isReferenceProperty(final Node node, final String propertyName) throws RepositoryException { final Optional<PropertyDefinition> propertyDefinition = getDefinitionForPropertyName(node, propertyName); return propertyDefinition.isPresent() && (propertyDefinition.get().getRequiredType() == REFERENCE || propertyDefinition.get().getRequiredType() == WEAKREFERENCE); }
@Override public Type getType() { return asType(this.propertyDef.getRequiredType()); }
@Override public List<? extends String> getChoices() { if (PropertyDialog.this.name != null) { List<PropertyDefinition> propdefs = choiceModel.getObject().get(PropertyDialog.this.name); if (propdefs != null) { List<String> result = new ArrayList<>(propdefs.size()); for (PropertyDefinition pd : propdefs) { result.add(PropertyType.nameFromValue(pd.getRequiredType())); } return result; } } return ALL_TYPES; } };
protected PropertyDefinition findDefinition(NodeType nodeType, String name, int type, boolean multiValued) { PropertyDefinition best = null; for (PropertyDefinition pdef : nodeType.getPropertyDefinitions()) { if (pdef.getName().equals(name) && pdef.isMultiple() == multiValued) { if ((!"*".equals(name) && type == JcrPropertyValueModel.NO_TYPE) || pdef.getRequiredType() == type) { return pdef; } else if (pdef.getRequiredType() == PropertyType.UNDEFINED) { best = pdef; } } } return best; }
protected PropertyDefinition findDefinition(NodeType nodeType, String name, int type, boolean multiValued) { PropertyDefinition best = null; for (PropertyDefinition pdef : nodeType.getPropertyDefinitions()) { if (pdef.getName().equals(name) && pdef.isMultiple() == multiValued) { if (type == PropertyType.UNDEFINED || type == JcrPropertyValueModel.NO_TYPE || pdef.getRequiredType() == type) { return pdef; } else if (pdef.getRequiredType() == PropertyType.UNDEFINED) { best = pdef; } } } return best; }
private boolean canSetProperty(NodeType nodeType, String propertyName, int propertyType, boolean isMultiple) { PropertyDefinition propDefs[] = nodeType.getPropertyDefinitions(); for (int i = 0; i < propDefs.length; i++) { if (propDefs[i].getName().equals(propertyName) || propDefs[i].getName().equals("*")) { if ((propDefs[i].getRequiredType() == propertyType || propDefs[i].getRequiredType() == PropertyType.UNDEFINED) && propDefs[i].isMultiple() == isMultiple) { return true; } } } return false; }
private PropertyDefinition getMatchingPropDef(PropertyDefinition[] pdfs, int type, String name, boolean isMultiValued) { for (PropertyDefinition pd : pdfs) { int reqType = pd.getRequiredType(); if ((name.equals(pd.getName()) && (isMultiValued == pd.isMultiple()) // || reqType == PropertyType.UNDEFINED // || type == PropertyType.UNDEFINED))) )) { return pd; } } return null; }
public PropertyDefinitionInfo(PropertyDefinition propertyDefinition) { this.name = propertyDefinition.getName(); this.type = propertyDefinition.getRequiredType(); this.multiple = propertyDefinition.isMultiple(); }
private PropertyDefinition mockPropDef(int type, boolean isMultiple) { PropertyDefinition def = Mockito.mock(PropertyDefinition.class); when(def.getRequiredType()).thenReturn(type); when(def.isMultiple()).thenReturn(isMultiple); return def; }
public PropertyDefinitionValue(PropertyDefinition propertyDefinition) throws RepositoryException { super(propertyDefinition); this.defaultValueStrings = convert(propertyDefinition.getDefaultValues()); this.multiple = propertyDefinition.isMultiple(); this.requiredType = propertyDefinition.getRequiredType(); this.valueConstraints = propertyDefinition.getValueConstraints() != null ? Arrays.asList(propertyDefinition.getValueConstraints()) : new ArrayList<String>();; }
/** * Helper method to test the type received with Value.getType() and * Property.getType() . */ public static boolean checkGetType(Property prop, int propType) throws RepositoryException { Value val = getValue(prop); boolean samePropType = (val.getType() == propType); int requiredType = prop.getDefinition().getRequiredType(); if (requiredType != PropertyType.UNDEFINED) { samePropType = (val.getType() == requiredType); } return samePropType; }
private PropertyDefinitionImpl(PropertyDefinition definition) { super(definition); type = definition.getRequiredType(); valueConstraints = definition.getValueConstraints(); defaultValues = definition.getDefaultValues(); isMultiple = definition.isMultiple(); availableQueryOperators = definition.getAvailableQueryOperators(); isFullTextSearchable = definition.isFullTextSearchable(); isQueryOrderable = definition.isQueryOrderable(); }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
@Test @FixFor( "MODE-1722" ) public void shouldRegisterNodeTypeWithUriPropertyType() throws Exception { startRepository(); registerNodeTypes("cnd/nodetype-with-uri-property.cnd"); NodeTypeManager ntmgr = session.getWorkspace().getNodeTypeManager(); NodeType nt = ntmgr.getNodeType("ex:myNodeType"); PropertyDefinition uriPropDefn = nt.getDeclaredPropertyDefinitions()[0]; assertLocalNameAndNamespace(nt, "myNodeType", "ex"); assertThat(uriPropDefn.getName(), is("ex:path")); assertThat(uriPropDefn.getRequiredType(), is(PropertyType.URI)); }
public void testStringRequiredTypeBoolean() throws Exception { Value stringValue = superuser.getValueFactory().createValue("true", PropertyType.STRING); Property p = node.setProperty(BOOLEAN_PROP_NAME, stringValue); assertEquals(PropertyType.BOOLEAN, p.getType()); assertEquals(PropertyType.BOOLEAN, p.getValue().getType()); assertTrue(p.getBoolean()); PropertyDefinition def = p.getDefinition(); assertEquals(PropertyType.BOOLEAN, def.getRequiredType()); assertEquals(NT_NAME, def.getDeclaringNodeType().getName()); }