/** * Finds the aspect type that contains the given property id. */ public static ObjectType findAspect(Collection<ObjectType> aspectTypes, String propertyId) { if (aspectTypes == null || propertyId == null) { return null; } for (ObjectType type : aspectTypes) { if (type != null && type.getPropertyDefinitions() != null && type.getPropertyDefinitions().containsKey(propertyId)) { return type; } } return null; }
public Map<String, PropertyDefinition<?>> getPropertyDefinitions() { Map<String, PropertyDefinition<?>> result = new HashMap<String, PropertyDefinition<?>>(folder.getType() .getPropertyDefinitions()); for (ObjectType aspect : folder.getAspects()) { result.putAll(aspect.getPropertyDefinitions()); } return result; }
public Map<String, PropertyDefinition<?>> getPropertyDefinitions() { Map<String, PropertyDefinition<?>> result = new HashMap<String, PropertyDefinition<?>>( doc.getType().getPropertyDefinitions()); for (ObjectType aspect : doc.getAspects()) { result.putAll(aspect.getPropertyDefinitions()); } return result; }
protected String[] getAllProperties(CmisObject object) { String[] propertiesk = new String[object.getType().getPropertyDefinitions().size()]; int i = 0; for (String propId : object.getType().getPropertyDefinitions().keySet()) { propertiesk[i++] = propId; } return propertiesk; }
@Override public void setProperty(int parameterIndex, String typeId, String propertyId) { ObjectType type = session.getTypeDefinition(typeId); PropertyDefinition<?> propertyDefinition = type.getPropertyDefinitions().get(propertyId); if (propertyDefinition == null) { throw new IllegalArgumentException("Property does not exist!"); } setProperty(parameterIndex, propertyDefinition); }
@Override public void setProperty(int parameterIndex, String typeId, String propertyId) { ObjectType type = session.getTypeDefinition(typeId); PropertyDefinition<?> propertyDefinition = type.getPropertyDefinitions().get(propertyId); if (propertyDefinition == null) { throw new IllegalArgumentException("Property does not exist!"); } setProperty(parameterIndex, propertyDefinition); }
@Override public Map<String, Property<?>> convertProperties(ObjectType objectType, Collection<SecondaryType> secondaryTypes, Properties properties) { // check input if (objectType == null) { throw new IllegalArgumentException("Object type must set!"); } if (objectType.getPropertyDefinitions() == null) { throw new IllegalArgumentException("Object type has no property defintions!"); } if (properties == null || properties.getProperties() == null) { throw new IllegalArgumentException("Properties must be set!"); } // iterate through properties and convert them Map<String, Property<?>> result = new LinkedHashMap<String, Property<?>>(); for (Map.Entry<String, PropertyData<?>> entry : properties.getProperties().entrySet()) { // find property definition Property<?> apiProperty = convertProperty(objectType, secondaryTypes, entry.getValue()); result.put(entry.getKey(), apiProperty); } return result; }
@Override public Map<String, Property<?>> convertProperties(ObjectType objectType, Collection<SecondaryType> secondaryTypes, Properties properties) { // check input if (objectType == null) { throw new IllegalArgumentException("Object type must set!"); } if (objectType.getPropertyDefinitions() == null) { throw new IllegalArgumentException("Object type has no property defintions!"); } if (properties == null || properties.getProperties() == null) { throw new IllegalArgumentException("Properties must be set!"); } // iterate through properties and convert them Map<String, Property<?>> result = new LinkedHashMap<String, Property<?>>(); for (Map.Entry<String, PropertyData<?>> entry : properties.getProperties().entrySet()) { // find property definition Property<?> apiProperty = convertProperty(objectType, secondaryTypes, entry.getValue()); result.put(entry.getKey(), apiProperty); } return result; }
/** * Returns the query name of a property. */ protected String getPropertyQueryName(String propertyId) { readLock(); try { PropertyDefinition<?> propDef = objectType.getPropertyDefinitions().get(propertyId); if (propDef == null) { return null; } return propDef.getQueryName(); } finally { readUnlock(); } }
@Override public List<ObjectType> findObjectType(String id) { List<ObjectType> result = null; readLock(); try { if (objectType.getPropertyDefinitions().containsKey(id)) { result = new ArrayList<ObjectType>(); result.add(objectType); } if (secondaryTypes != null) { for (SecondaryType secondaryType : secondaryTypes) { if (secondaryType.getPropertyDefinitions() != null && secondaryType.getPropertyDefinitions().containsKey(id)) { if (result == null) { result = new ArrayList<ObjectType>(); } result.add(secondaryType); } } } } finally { readUnlock(); } return result; }
/** * Returns the query name of a property. */ protected String getPropertyQueryName(String propertyId) { readLock(); try { PropertyDefinition<?> propDef = objectType.getPropertyDefinitions().get(propertyId); if (propDef == null) { return null; } return propDef.getQueryName(); } finally { readUnlock(); } }
@Override public List<ObjectType> findObjectType(String id) { List<ObjectType> result = null; readLock(); try { if (objectType.getPropertyDefinitions().containsKey(id)) { result = new ArrayList<ObjectType>(); result.add(objectType); } if (secondaryTypes != null) { for (SecondaryType secondaryType : secondaryTypes) { if (secondaryType.getPropertyDefinitions() != null && secondaryType.getPropertyDefinitions().containsKey(id)) { if (result == null) { result = new ArrayList<ObjectType>(); } result.add(secondaryType); } } } } finally { readUnlock(); } return result; }
@SuppressWarnings("unchecked") @Override protected Properties prepareProperties() { ObjectType type = getType(); PropertyDefinition<String> propDef = (PropertyDefinition<String>) type.getPropertyDefinitions().get( PropertyIds.OBJECT_TYPE_ID); String objectTypeIdValue = AlfrescoAspectsUtils.createObjectTypeIdValue(type, getAspects()); Property<String> objectTypeIdProperty = getObjectFactory().createProperty(propDef, Collections.singletonList(objectTypeIdValue)); properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeIdProperty); return super.prepareProperties(); } }
@SuppressWarnings("unchecked") @Override protected Properties prepareProperties() { ObjectType type = getType(); PropertyDefinition<String> propDef = (PropertyDefinition<String>) type .getPropertyDefinitions().get(PropertyIds.OBJECT_TYPE_ID); String objectTypeIdValue = AlfrescoAspectsUtils .createObjectTypeIdValue(type, getAspects()); Property<String> objectTypeIdProperty = getObjectFactory() .createProperty(propDef, Collections.singletonList(objectTypeIdValue)); properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeIdProperty); return super.prepareProperties(); } }
@SuppressWarnings("unchecked") public <T> void setPropertyValue(String id, Object value) { ObjectType aspectType = aspects.findAspect(id); if (aspectType == null) { super.setPropertyValue(id, value); return; } PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>) aspectType.getPropertyDefinitions().get(id); if (propertyDefinition == null) { throw new IllegalArgumentException("Unknown property '" + id + "'!"); } // check updatability if (propertyDefinition.getUpdatability() == Updatability.READONLY) { throw new IllegalArgumentException("Property is read-only!"); } List<T> values = AlfrescoAspectsUtils.checkProperty(propertyDefinition, value); // create and set property Property<T> newProperty = getObjectFactory().createProperty(propertyDefinition, values); properties.put(id, newProperty); isPropertyUpdateRequired = true; isModified = true; }
@SuppressWarnings("unchecked") public <T> void setPropertyValue(String id, Object value) { ObjectType aspectType = aspects.findAspect(id); if (aspectType == null) { super.setPropertyValue(id, value); return; } PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>) aspectType .getPropertyDefinitions().get(id); if (propertyDefinition == null) { throw new IllegalArgumentException("Unknown property '" + id + "'!"); } // check updatability if (propertyDefinition.getUpdatability() == Updatability.READONLY) { throw new IllegalArgumentException("Property is read-only!"); } List<T> values = AlfrescoAspectsUtils.checkProperty(propertyDefinition, value); // create and set property Property<T> newProperty = getObjectFactory().createProperty( propertyDefinition, values); properties.put(id, newProperty); isPropertyUpdateRequired = true; isModified = true; }
PropertyDefinition<?> idPropDef = folderType.getPropertyDefinitions().get(PropertyIds.OBJECT_ID); PropertyDefinition<?> pathPropDef = folderType.getPropertyDefinitions().get(PropertyIds.PATH); if (idPropDef != null && pathPropDef != null) { filter = idPropDef.getQueryName() + "," + pathPropDef.getQueryName();
addResult(results, createResult(FAILURE, "Query result is empty!")); } else { for (PropertyDefinition<?> propDef : type.getPropertyDefinitions().values()) { if (propDef.getQueryName() == null) { continue;
public void runFolderQuery(Session session, Folder testFolder) { if (!Boolean.TRUE.equals(testFolder.getType().isQueryable())) { addResult(createResult(SKIPPED, "Folder type '" + testFolder.getType().getId() + "' is not queryable. Folder query test skipped!")); return; } CmisTestResult f; QueryStatement[] statements = new QueryStatement[] { session.createQueryStatement("SELECT * FROM ? WHERE ? = ?"), session.createQueryStatement("SELECT * FROM ? WHERE ? IN (?)") }; for (QueryStatement statement : statements) { statement.setType(1, testFolder.getType()); statement.setProperty(2, testFolder.getType().getPropertyDefinitions().get(PropertyIds.OBJECT_ID)); statement.setString(3, testFolder.getId()); addResult(createInfoResult("Folder query: " + statement.toQueryString())); int count = 0; for (QueryResult qr : statement.query(false)) { count++; String objectId = qr.getPropertyValueByQueryName("cmis:objectId"); f = createResult(FAILURE, "Folder query returned unexpected object. Id: " + objectId); addResult(assertEquals(testFolder.getId(), objectId, null, f)); } f = createResult(FAILURE, "Folder query should return exactly one hit, but returned " + count + "."); addResult(assertEquals(1, count, null, f)); } }
statement.setProperty(2, testDocument.getType().getPropertyDefinitions().get(PropertyIds.OBJECT_ID)); statement.setString(3, testDocument.getId());