use of org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createTypeWithProperties.
private void createTypeWithProperties(Session session, ObjectType parentType) {
CmisTestResult failure = null;
CreatablePropertyTypes cpt = session.getRepositoryInfo().getCapabilities().getCreatablePropertyTypes();
if (cpt == null || cpt.canCreate() == null || cpt.canCreate().isEmpty()) {
addResult(createResult(FAILURE, "Repository Info does not indicate, which property types can be created!"));
return;
}
// define the type
DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_with_properties", parentType);
// add a property for each creatable property type
for (PropertyType propType : PropertyType.values()) {
if (!cpt.canCreate().contains(propType)) {
continue;
}
newTypeDef.addPropertyDefinition(createPropertyDefinition(propType));
}
// create the type
ObjectType newType = createType(session, newTypeDef);
if (newType == null) {
return;
}
// get the type
ObjectType newType2 = null;
try {
newType2 = session.getTypeDefinition(newType.getId());
// assert type definitions
failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
addResult(assertEquals(newType, newType2, null, failure));
} catch (CmisObjectNotFoundException e) {
addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
}
// check properties
List<PropertyDefinition<?>> newPropDefs = new ArrayList<PropertyDefinition<?>>();
for (Map.Entry<String, PropertyDefinition<?>> propDef : newType.getPropertyDefinitions().entrySet()) {
if (Boolean.FALSE.equals(propDef.getValue().isInherited())) {
newPropDefs.add(propDef.getValue());
}
}
failure = createResult(FAILURE, "The number of defined properties and the number of non-inherited properties don't match!");
addResult(assertEquals(newTypeDef.getPropertyDefinitions().size(), newPropDefs.size(), null, failure));
// check the order of the properties, which must match the order of the
// original type definition
// (OpenCMIS keeps the order of the property definitions.)
int i = 0;
for (Map.Entry<String, PropertyDefinition<?>> propDef : newTypeDef.getPropertyDefinitions().entrySet()) {
PropertyDefinition<?> newPropDef = newPropDefs.get(i);
failure = createResult(FAILURE, "Property " + (i + 1) + " must be of type " + propDef.getValue().getPropertyType() + " but is of type " + newPropDef.getPropertyType() + "!");
addResult(assertEquals(propDef.getValue().getPropertyType(), newPropDef.getPropertyType(), null, failure));
addResult(createInfoResult("Repository assigned the property '" + propDef.getValue().getId() + "' the following property id: " + newPropDef.getId()));
i++;
}
// delete the type
deleteType(session, newType.getId());
}
use of org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition in project copper-cms by PogeyanOSS.
the class CmisTypeCacheService method getPropertyDefinition.
@Override
public PropertyDefinition<?> getPropertyDefinition(String propId) {
MTypeManagerDAO typeMorphiaDAO = DatabaseServiceFactory.getInstance(repositoryId).getObjectService(repositoryId, MTypeManagerDAO.class);
Map<String, PropertyDefinition<?>> property = typeMorphiaDAO.getAllPropertyById(propId);
return property.get(propId);
}
use of org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition in project copper-cms by PogeyanOSS.
the class MTypeObject method getPropertyDefinitions.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map<String, PropertyDefinition<?>> getPropertyDefinitions() {
Map<String, PropertyDefinition<?>> map = new LinkedHashMap<String, PropertyDefinition<?>>();
if (propertyDefinition != null) {
Set<Entry<String, MongoPropertyDefinition<?>>> data = propertyDefinition.entrySet();
for (Map.Entry<String, MongoPropertyDefinition<?>> propertiesValues : data) {
String id = propertiesValues.getKey();
PropertyDefinitionImpl<?> valueName = propertiesValues.getValue();
String propertyType = valueName.getPropertyType().toString();
if (propertyType.equalsIgnoreCase("string")) {
CmisPropertyStringDefinitionImpl propertyValue = new CmisPropertyStringDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("boolean")) {
CmisPropertyBooleanDefinitionImpl propertyValue = new CmisPropertyBooleanDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("id")) {
CmisPropertyIdDefinitionImpl propertyValue = new CmisPropertyIdDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("datetime")) {
CmisPropertyDateTimeDefinitionImpl propertyValue = new CmisPropertyDateTimeDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("decimal")) {
CmisPropertyDecimalDefinitionImpl propertyValue = new CmisPropertyDecimalDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("html")) {
CmisPropertyHtmlDefinitionImpl propertyValue = new CmisPropertyHtmlDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("uri")) {
CmisPropertyUriDefinitionImpl propertyValue = new CmisPropertyUriDefinitionImpl(valueName);
map.put(id, propertyValue);
} else if (propertyType.equalsIgnoreCase("integer")) {
CmisPropertyIntegerDefinitionImpl propertyValue = new CmisPropertyIntegerDefinitionImpl(valueName);
map.put(id, propertyValue);
}
}
}
return map;
}
use of org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method assertEquals.
protected CmisTestResult assertEquals(TypeDefinition expected, TypeDefinition actual, CmisTestResult success, CmisTestResult failure) {
List<CmisTestResult> results = new ArrayList<CmisTestResult>();
CmisTestResult f;
if ((expected == null) && (actual == null)) {
return success;
}
if (expected == null) {
f = createResult(FAILURE, "Expected type defintion is null, but actual type defintion is not!");
addResultChild(failure, f);
return failure;
}
if (actual == null) {
f = createResult(FAILURE, "Actual type defintion is null, but expected type defintion is not!");
addResultChild(failure, f);
return failure;
}
f = createResult(FAILURE, "Type IDs don't match!");
addResult(results, assertEquals(expected.getId(), actual.getId(), null, f));
f = createResult(FAILURE, "Base type IDs don't match!");
addResult(results, assertEquals(expected.getBaseTypeId(), actual.getBaseTypeId(), null, f));
f = createResult(FAILURE, "Parent type IDs don't match!");
addResult(results, assertEquals(expected.getParentTypeId(), actual.getParentTypeId(), null, f));
f = createResult(FAILURE, "Query names don't match!");
addResult(results, assertEquals(expected.getQueryName(), actual.getQueryName(), null, f));
f = createResult(FAILURE, "Local names don't match!");
addResult(results, assertEquals(expected.getLocalName(), actual.getLocalName(), null, f));
f = createResult(FAILURE, "Local namespaces don't match!");
addResult(results, assertEquals(expected.getLocalNamespace(), actual.getLocalNamespace(), null, f));
f = createResult(FAILURE, "Display names don't match!");
addResult(results, assertEquals(expected.getDisplayName(), actual.getDisplayName(), null, f));
f = createResult(FAILURE, "Descriptions don't match!");
addResult(results, assertEquals(expected.getDescription(), actual.getDescription(), null, f));
f = createResult(FAILURE, "Controllable ACl flags don't match!");
addResult(results, assertEquals(expected.isControllableAcl(), actual.isControllableAcl(), null, f));
f = createResult(FAILURE, "Controllable Policy flags don't match!");
addResult(results, assertEquals(expected.isControllablePolicy(), actual.isControllablePolicy(), null, f));
f = createResult(FAILURE, "Creatable flags don't match!");
addResult(results, assertEquals(expected.isCreatable(), actual.isCreatable(), null, f));
f = createResult(FAILURE, "Fileable flags don't match!");
addResult(results, assertEquals(expected.isFileable(), actual.isFileable(), null, f));
f = createResult(FAILURE, "Fulltext indexed flags don't match!");
addResult(results, assertEquals(expected.isFulltextIndexed(), actual.isFulltextIndexed(), null, f));
f = createResult(FAILURE, "Queryable flags don't match!");
addResult(results, assertEquals(expected.isQueryable(), actual.isQueryable(), null, f));
f = createResult(FAILURE, "Included in supertype query flags don't match!");
addResult(results, assertEquals(expected.isIncludedInSupertypeQuery(), actual.isIncludedInSupertypeQuery(), null, f));
if (expected.getTypeMutability() != null && actual.getTypeMutability() != null) {
f = createResult(FAILURE, "Type Mutability: Create flags don't match!");
addResult(results, assertEquals(expected.getTypeMutability().canCreate(), actual.getTypeMutability().canCreate(), null, f));
f = createResult(FAILURE, "Type Mutability: update flags don't match!");
addResult(results, assertEquals(expected.getTypeMutability().canUpdate(), actual.getTypeMutability().canUpdate(), null, f));
f = createResult(FAILURE, "Type Mutability: delete flags don't match!");
addResult(results, assertEquals(expected.getTypeMutability().canDelete(), actual.getTypeMutability().canDelete(), null, f));
} else {
f = createResult(FAILURE, "Type Mutability infos don't match!");
addResult(results, assertEquals(expected.getTypeMutability(), actual.getTypeMutability(), null, f));
}
if ((expected.getPropertyDefinitions() != null) && (actual.getPropertyDefinitions() != null)) {
Map<String, PropertyDefinition<?>> epd = expected.getPropertyDefinitions();
Map<String, PropertyDefinition<?>> apd = actual.getPropertyDefinitions();
f = createResult(FAILURE, "Different number of property defintions!");
addResult(results, assertEquals(epd.size(), apd.size(), null, f));
for (PropertyDefinition<?> pd : epd.values()) {
f = createResult(FAILURE, "Property definition mismatch: " + pd.getId());
addResult(results, assertEquals(pd, apd.get(pd.getId()), null, f));
}
}
if (getWorst(results).getLevel() <= OK.getLevel()) {
for (CmisTestResult result : results) {
addResultChild(success, result);
}
return success;
} else {
for (CmisTestResult result : results) {
addResultChild(failure, result);
}
return failure;
}
}
Aggregations