/** {@inheritDoc} */ public boolean isMultiple() throws RepositoryException { // TODO: Direct remote call for this? return getDefinition().isMultiple(); }
private boolean isValid(@NotNull PropInfo propInfo, @NotNull PropertyDefinition def) { if (REP_PRINCIPAL_NAMES.equals(propInfo.getName())) { return def.isMultiple() && NT_REP_CUG_POLICY.equals(def.getDeclaringNodeType().getName()); } return false; } }
private boolean isValid(@NotNull PropInfo propInfo, @NotNull PropertyDefinition def) { if (REP_PRINCIPAL_NAMES.equals(propInfo.getName())) { return def.isMultiple() && NT_REP_CUG_POLICY.equals(def.getDeclaringNodeType().getName()); } return false; } }
private Map<String, PropertyValue> getColumnMap(String selector, NodeType type) throws RepositoryException { Map<String, PropertyValue> map = new LinkedHashMap<String, PropertyValue>(); for (PropertyDefinition definition : type.getPropertyDefinitions()) { String name = definition.getName(); if (!definition.isMultiple() && !"*".equals(name)) { // TODO: Add proper quoting map.put(selector + "." + name, qomFactory.propertyValue(selector, name)); } } return map; }
public PropertyState asPropertyState(@NotNull PropertyDefinition propertyDefinition) throws RepositoryException { List<Value> vs = getValues(getTargetType(propertyDefinition)); PropertyState propertyState; if (vs.size() == 1 && !propertyDefinition.isMultiple()) { propertyState = PropertyStates.createProperty(name, vs.get(0)); } else { propertyState = PropertyStates.createProperty(name, vs); } return propertyState; } }
public PropertyState asPropertyState(@Nonnull PropertyDefinition propertyDefinition) throws RepositoryException { List<Value> vs = getValues(getTargetType(propertyDefinition)); PropertyState propertyState; if (vs.size() == 1 && !propertyDefinition.isMultiple()) { propertyState = PropertyStates.createProperty(name, vs.get(0)); } else { propertyState = PropertyStates.createProperty(name, vs); } return propertyState; } }
public boolean isPropertyMultiple(final Object node, final String name) throws PersistenceException { try { final Property prop = ((Node)node).getProperty(name); return prop.getDefinition().isMultiple(); } catch ( final RepositoryException re) { throw new PersistenceException(re.getMessage(), re); } }
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>();; }
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; }
/** * Tests if isMultiple() is consistent with PropertyDefinition.isMultiple(). */ public void testIsMultiple() throws RepositoryException { assertEquals("Property.isMultiple() must be consistent with PropertyDefinition.isMultiple()", property.isMultiple(), property.getDefinition().isMultiple()); }
PropertyDefinition mockPropertyDefinition(@NotNull String declaringNt, boolean mv) throws Exception { PropertyDefinition def = Mockito.mock(PropertyDefinition.class); when(def.isMultiple()).thenReturn(mv); when(def.getDeclaringNodeType()).thenReturn(ReadOnlyNodeTypeManager.getInstance(root, getNamePathMapper()).getNodeType(declaringNt)); return def; }
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(); }
@Test public void shouldIndicateHasSingleValue() throws Exception { prop = cars.getProperty("booleanProperty"); PropertyDefinition def = prop.getDefinition(); assertThat(def.isMultiple(), is(false)); }
public void testEmptyValues() throws Exception { superuser.importXML(targetPath, getImportStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); superuser.save(); Node n = superuser.getNode(targetPath).getNode(nodeName4); Property p = n.getNode(nodeName3).getProperty("test:multiProperty"); assertTrue(p.isMultiple()); assertTrue(p.getDefinition().isMultiple()); Assert.assertArrayEquals(new String[0], p.getValues()); } }
public void testSingleValues() throws Exception { superuser.importXML(targetPath, getImportStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); superuser.save(); Node n = superuser.getNode(targetPath).getNode(nodeName4); Property p = n.getNode(nodeName1).getProperty("test:multiProperty"); assertTrue(p.isMultiple()); assertTrue(p.getDefinition().isMultiple()); Assert.assertArrayEquals(new Value[]{vf.createValue("v1")}, p.getValues()); }
public void testMultiValues() throws Exception { superuser.importXML(targetPath, getImportStream(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); superuser.save(); Node n = superuser.getNode(targetPath).getNode(nodeName4); Property p = n.getNode(nodeName2).getProperty("test:multiProperty"); assertTrue(p.isMultiple()); assertTrue(p.getDefinition().isMultiple()); Value[] expected = new Value[] {vf.createValue("v1"), vf.createValue("v2")}; Assert.assertArrayEquals(expected, p.getValues()); }
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 public void testDefaultPropertyDefinition() throws Exception { // GIVEN // WHEN Property property = new MockProperty("test", new MockValue("value"), null); // THEN assertThat(property.getDefinition(), instanceOf(MockPropertyDefinition.class)); assertThat(property.getDefinition().isMultiple(), is(false)); assertThat(property.getDefinition().isMandatory(), is(false)); }