This project has retired. For details please refer to its
Attic page.
VersionTestTypeSystemCreator xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.inmemory;
2021import java.util.HashMap;
22import java.util.LinkedList;
23import java.util.List;
24import java.util.Map;
2526import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
27import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
28import org.apache.chemistry.opencmis.commons.enums.Updatability;
29import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
30import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
31import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
3233publicclassVersionTestTypeSystemCreator implements TypeCreator {
34publicstaticfinal String VERSION_TEST_DOCUMENT_TYPE_ID = "MyVersionedType";
35publicstaticfinal String PROPERTY_ID = "StringProp";
36publicstaticfinal List<TypeDefinition> singletonTypes = buildTypesList();
3738/**39 * in the public interface of this class we return the singleton containing40 * the required types for testing41 */42public List<TypeDefinition> createTypesList() {
43return singletonTypes;
44 }
4546publicstatic List<TypeDefinition> getTypesList() {
47return singletonTypes;
48 }
4950publicstatic TypeDefinition getTypeById(String typeId) {
51for (TypeDefinition typeDef : singletonTypes) {
52if (typeDef.getId().equals(typeId)) {
53return typeDef;
54 }
55 }
56returnnull;
57 }
5859/**60 * create root types and a collection of sample types61 *62 * @return typesMap map filled with created types63 */64privatestatic List<TypeDefinition> buildTypesList() {
65// always add CMIS default types66 List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
6768// create a complex type with properties69 InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(
70 VERSION_TEST_DOCUMENT_TYPE_ID, "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
7172// create a boolean property definition7374 Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
7576 PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID,
77"Sample String Property", Updatability.WHENCHECKEDOUT);
78 propertyDefinitions.put(prop1.getId(), prop1);
7980 cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
81 cmisComplexType.setIsVersionable(true); // make it a versionable type;8283// add type to types collection84 typesList.add(cmisComplexType);
8586return typesList;
87 }
8889 }