private static void testReturnedProperties(Map<String, PropertyData<?>> props) { for (PropertyData<?> pd : props.values()) { log.info("return property id: " + pd.getId() + ", value: " + pd.getValues()); } PropertyData<?> pd = props.get(PropertyIds.NAME); assertNotNull(pd); assertEquals(PROP_NAME, pd.getFirstValue()); pd = props.get(PropertyIds.OBJECT_TYPE_ID); assertEquals(VersionTestTypeSystemCreator.VERSION_TEST_DOCUMENT_TYPE_ID, pd.getFirstValue()); pd = props.get(VersionTestTypeSystemCreator.PROPERTY_ID); assertEquals(PROP_VALUE, pd.getFirstValue()); }
public static Map<String, Object> propertyDataToMap(List<? extends PropertyData<?>> properties) { Map<String, Object> result = new HashMap<String, Object>(); for (PropertyData<?> propertyData : properties) { result.put(propertyData.getId(), propertyData.getFirstValue()); } return result; }
private void constraintIntegerPropertyValue( PropertyDefinition<?> definition, PropertyData<?> propertyData, String objectId) { final String msg = "AN INTEGER property violates the range constraints"; BigInteger val = BigInteger.valueOf((Long) propertyData.getFirstValue()); BigInteger min = ((PropertyIntegerDefinition) definition).getMinValue(); if (min != null && min.compareTo(val) > 0) { constraint(objectId, msg); } BigInteger max = ((PropertyIntegerDefinition) definition).getMinValue(); if (max != null && max.compareTo(val) < 0) { constraint(objectId, msg); } }
@Override public void updateObject( StoredObject so, Map<String, PropertyData<?>> newProperties, String user) { // nothing to do Map<String, PropertyData<?>> properties = so.getProperties(); for (String key : newProperties.keySet()) { PropertyData<?> value = newProperties.get(key); if (key.equals(PropertyIds.SECONDARY_OBJECT_TYPE_IDS)) { properties.put(key, value); // preserve it even if it is empty! } else if (null == value || value.getValues() == null || value.getFirstValue() == null) { // delete property properties.remove(key); } else { properties.put(key, value); } } // update system properties and secondary object type ids so.updateSystemBasePropertiesWhenModified(properties, user); properties.remove(PropertyIds.SECONDARY_OBJECT_TYPE_IDS); }