You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/08/08 10:40:27 UTC
svn commit: r1511617 [5/5] - in
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src:
main/java/org/apache/chemistry/opencmis/inmemory/
main/java/org/apache/chemistry/opencmis/inmemory/query/
main/java/org/apache/c...
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/UnitTestTypeSystemCreator.java Thu Aug 8 08:40:26 2013
@@ -25,15 +25,20 @@ package org.apache.chemistry.opencmis.in
*/
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDecimalDefinitionImpl;
@@ -42,10 +47,9 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
public class UnitTestTypeSystemCreator implements TypeCreator {
public static final List<TypeDefinition> singletonTypes = buildTypesList();
@@ -104,246 +108,288 @@ public class UnitTestTypeSystemCreator i
* @return typesMap map filled with created types
*/
private static List<TypeDefinition> buildTypesList() {
- // always add CMIS default types
+ TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
- InMemoryDocumentTypeDefinition cmisType1 = new InMemoryDocumentTypeDefinition("MyDocType1",
- "My Type 1 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
- typesList.add(cmisType1);
-
- InMemoryDocumentTypeDefinition cmisType2 = new InMemoryDocumentTypeDefinition("MyDocType2",
- "My Type 2 Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
- typesList.add(cmisType2);
-
- InMemoryDocumentTypeDefinition cmisType11 = new InMemoryDocumentTypeDefinition("MyDocType1.1",
- "My Type 3 Level 2", cmisType1);
- typesList.add(cmisType11);
-
- InMemoryDocumentTypeDefinition cmisType111 = new InMemoryDocumentTypeDefinition("MyDocType1.1.1",
- "My Type 4 Level 3", cmisType11);
- typesList.add(cmisType111);
-
- InMemoryDocumentTypeDefinition cmisType112 = new InMemoryDocumentTypeDefinition("MyDocType1.1.2",
- "My Type 5 Level 3", cmisType11);
- typesList.add(cmisType112);
-
- InMemoryDocumentTypeDefinition cmisType12 = new InMemoryDocumentTypeDefinition("MyDocType1.2",
- "My Type 6 Level 2", cmisType1);
- typesList.add(cmisType12);
-
- InMemoryDocumentTypeDefinition cmisType21 = new InMemoryDocumentTypeDefinition("MyDocType2.1",
- "My Type 7 Level 2", cmisType2);
- typesList.add(cmisType21);
-
- InMemoryDocumentTypeDefinition cmisType22 = new InMemoryDocumentTypeDefinition("MyDocType2.2",
- "My Type 8 Level 2", cmisType2);
- typesList.add(cmisType22);
- InMemoryDocumentTypeDefinition cmisType23 = new InMemoryDocumentTypeDefinition("MyDocType2.3",
- "My Type 9 Level 2", cmisType2);
- typesList.add(cmisType23);
- InMemoryDocumentTypeDefinition cmisType24 = new InMemoryDocumentTypeDefinition("MyDocType2.4",
- "My Type 10 Level 2", cmisType2);
- typesList.add(cmisType24);
- InMemoryDocumentTypeDefinition cmisType25 = new InMemoryDocumentTypeDefinition("MyDocType2.5",
- "My Type 11 Level 2", cmisType2);
- typesList.add(cmisType25);
-
- InMemoryDocumentTypeDefinition cmisType26 = new InMemoryDocumentTypeDefinition("MyDocType2.6",
- "My Type 12 Level 2", cmisType2);
- typesList.add(cmisType26);
- InMemoryDocumentTypeDefinition cmisType27 = new InMemoryDocumentTypeDefinition("MyDocType2.7",
- "My Type 13 Level 2", cmisType2);
- typesList.add(cmisType27);
- InMemoryDocumentTypeDefinition cmisType28 = new InMemoryDocumentTypeDefinition("MyDocType2.8",
- "My Type 14 Level 2", cmisType2);
- typesList.add(cmisType28);
- InMemoryDocumentTypeDefinition cmisType29 = new InMemoryDocumentTypeDefinition("MyDocType2.9",
- "My Type 15 Level 2", cmisType2);
- typesList.add(cmisType29);
-
- // create a complex type with properties
- InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(COMPLEX_TYPE,
- "Complex type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a boolean property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition(PROP_ID_BOOLEAN,
- "Sample Boolean Property", Updatability.READONLY);
- propertyDefinitions.put(prop.getId(), prop);
-
- prop = PropertyCreationHelper.createBooleanMultiDefinition(PROP_ID_BOOLEAN_MULTI_VALUE,
- "Sample Boolean multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop.getId(), prop);
-
- PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition(PROP_ID_DATETIME,
- "Sample DateTime Property", Updatability.READONLY);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- prop2 = PropertyCreationHelper.createDateTimeMultiDefinition(PROP_ID_DATETIME_MULTI_VALUE,
- "Sample DateTime multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition(PROP_ID_DECIMAL,
- "Sample Decimal Property", Updatability.READONLY);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- prop3 = PropertyCreationHelper.createDecimalMultiDefinition(PROP_ID_DECIMAL_MULTI_VALUE, "Sample Decimal multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition(PROP_ID_HTML,
- "Sample Html Property", Updatability.READONLY);
- propertyDefinitions.put(prop4.getId(), prop4);
-
- prop4 = PropertyCreationHelper.createHtmlDefinition(PROP_ID_HTML_MULTI_VALUE, "Sample Html multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop4.getId(), prop4);
-
- PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition(PROP_ID_ID, "Sample Id Property", Updatability.READONLY);
- propertyDefinitions.put(prop5.getId(), prop5);
-
- prop5 = PropertyCreationHelper.createIdMultiDefinition(PROP_ID_ID_MULTI_VALUE, "Sample Id Html multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop5.getId(), prop5);
-
- PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT,
- "Sample Int Property", Updatability.READONLY);
- propertyDefinitions.put(prop6.getId(), prop6);
-
- prop6 = PropertyCreationHelper.createIntegerMultiDefinition(PROP_ID_INT_MULTI_VALUE, "Sample Int multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop6.getId(), prop6);
-
- PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
- "Sample String Property", Updatability.READONLY);
- propertyDefinitions.put(prop7.getId(), prop7);
-
- prop7 = PropertyCreationHelper.createStringMultiDefinition(PROP_ID_STRING_MULTI_VALUE,
- "Sample String multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop7.getId(), prop7);
-
- PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition(PROP_ID_URI, "Sample Uri Property", Updatability.READONLY);
- propertyDefinitions.put(prop8.getId(), prop8);
-
- prop8 = PropertyCreationHelper.createUriMultiDefinition(PROP_ID_URI_MULTI_VALUE, "Sample Uri multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop8.getId(), prop8);
-
- PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
- "Sample Pick List Property", Updatability.READONLY);
- List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
- ChoiceImpl<String> elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("red"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("green"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("blue"));
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("black"));
- choiceList.add(elem);
- prop9.setChoices(choiceList);
- prop9.setDefaultValue(Collections.singletonList("blue"));
- propertyDefinitions.put(prop9.getId(), prop9);
-
- /*
- * try short form: / PropertyCreationHelper.addElemToPicklist(prop9,
- * "red"); PropertyCreationHelper.addElemToPicklist(prop9, "green");
- * PropertyCreationHelper.addElemToPicklist(prop9, "blue");
- * PropertyCreationHelper.addElemToPicklist(prop9, "black");
- * PropertyCreationHelper.setDefaultValue(prop9, "blue"); /
- */
-
- cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
-
- // add type to types collection
- typesList.add(cmisComplexType);
-
- // create a type hierarchy with inherited properties
- InMemoryDocumentTypeDefinition cmisDocTypeTopLevel = new InMemoryDocumentTypeDefinition(TOPLEVEL_TYPE,
- "Document type with properties, Level 1", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- InMemoryDocumentTypeDefinition cmisDocTypeLevel1 = new InMemoryDocumentTypeDefinition(LEVEL1_TYPE,
- "Document type with inherited properties, Level 2", cmisDocTypeTopLevel);
-
- InMemoryDocumentTypeDefinition cmisDocTypeLevel2 = new InMemoryDocumentTypeDefinition(LEVEL2_TYPE,
- "Document type with inherited properties, Level 3", cmisDocTypeLevel1);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
- "Sample String Property", Updatability.READONLY);
- propertyDefinitions.put(propTop.getId(), propTop);
- cmisDocTypeTopLevel.addCustomPropertyDefinitions(propertyDefinitions);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
- "String Property Level 1", Updatability.READONLY);
- propertyDefinitions.put(propLevel1.getId(), propLevel1);
- cmisDocTypeLevel1.addCustomPropertyDefinitions(propertyDefinitions);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
- "String Property Level 2", Updatability.READONLY);
- propertyDefinitions.put(propLevel2.getId(), propLevel2);
- cmisDocTypeLevel2.addCustomPropertyDefinitions(propertyDefinitions);
-
- // create a versioned type with properties
- InMemoryDocumentTypeDefinition cmisVersionedType = new InMemoryDocumentTypeDefinition(VERSIONED_TYPE,
- "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a single String property definition
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(VERSION_PROPERTY_ID,
- "Sample String Property", Updatability.READONLY);
- propertyDefinitions.put(prop1.getId(), prop1);
-
- cmisVersionedType.addCustomPropertyDefinitions(propertyDefinitions);
- cmisVersionedType.setIsVersionable(true); // make it a versionable type;
-
- // create a folder type
- // create a complex type with properties
- InMemoryFolderTypeDefinition cmisFolderType = new InMemoryFolderTypeDefinition(FOLDER_TYPE,
- "Folder type with properties", InMemoryFolderTypeDefinition.getRootFolderType());
-
- // create a two property definitions for folder
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT, "Sample Folder Int Property", Updatability.READONLY);
- propertyDefinitions.put(prop6.getId(), prop6);
-
- prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
- "Sample Folder String Property", Updatability.READONLY);
- propertyDefinitions.put(prop7.getId(), prop7);
- cmisFolderType.addCustomPropertyDefinitions(propertyDefinitions);
-
- // CMIS 1.1 create a secondary type
- InMemorySecondaryTypeDefinition cmisSecondaryType = new InMemorySecondaryTypeDefinition(SECONDARY_TYPE,
- "MySecondaryType");
- // create a single String property definition
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl propStr = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
- "Secondary String Property", Updatability.READWRITE);
- propertyDefinitions.put(propStr.getId(), propStr);
- PropertyIntegerDefinitionImpl propInt = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
- "Secondary Integer Property", Updatability.READWRITE);
- propInt.setIsRequired(true);
- propertyDefinitions.put(propInt.getId(), propInt);
- cmisSecondaryType.addCustomPropertyDefinitions(propertyDefinitions);
-
- InMemorySecondaryTypeDefinition cmisSecondaryType2 = new InMemorySecondaryTypeDefinition(SECONDARY_TYPE_2,
- "MySecondaryType-2");
-
- // add type to types collectio
- typesList.add(cmisDocTypeTopLevel);
- typesList.add(cmisDocTypeLevel1);
- typesList.add(cmisDocTypeLevel2);
- typesList.add(cmisVersionedType);
- typesList.add(cmisFolderType);
- typesList.add(cmisSecondaryType);
- typesList.add(cmisSecondaryType2);
- return typesList;
+ try {
+ MutableTypeDefinition cmisType1;
+ cmisType1 = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), LEVEL1_TYPE);
+ cmisType1.setDisplayName("Document type with inherited properties, Level 2");
+ cmisType1.setDescription("Builtin InMemory type definition " + LEVEL1_TYPE);
+
+ cmisType1 = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), "MyDocType1");
+ cmisType1.setDisplayName("My Type 1 Level 1");
+ cmisType1.setDescription("Builtin InMemory type definition MyDocType1");
+ typesList.add(cmisType1);
+
+ MutableTypeDefinition cmisType2;
+ cmisType2 = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), "MyDocType2");
+ cmisType2.setDisplayName("My Type 2 Level 1");
+ cmisType2.setDescription("Builtin InMemory type definition MyDocType2");
+ typesList.add(cmisType2);
+
+ MutableTypeDefinition cmisType11;
+ cmisType11 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.1");
+ cmisType11.setDisplayName("My Type 3 Level 2");
+ cmisType11.setDescription("Builtin InMemory type definition MyDocType1.1");
+ typesList.add(cmisType11);
+
+ MutableTypeDefinition cmisType111;
+ cmisType111 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.1");
+ cmisType111.setDisplayName("My Type 4 Level 3");
+ cmisType111.setDescription("Builtin InMemory type definition MyDocType1.1.1");
+ typesList.add(cmisType111);
+
+ MutableTypeDefinition cmisType112;
+ cmisType112 = typeFactory.createChildTypeDefinition(cmisType11, "MyDocType1.1.2");
+ cmisType112.setDisplayName("My Type 5 Level 3");
+ cmisType112.setDescription("Builtin InMemory type definition MyDocType1.1.2");
+ typesList.add(cmisType112);
+
+ MutableTypeDefinition cmisType12;
+ cmisType12 = typeFactory.createChildTypeDefinition(cmisType1, "MyDocType1.2");
+ cmisType12.setDisplayName("My Type 6 Level 2");
+ cmisType12.setDescription("Builtin InMemory type definition MyDocType1.2");
+ typesList.add(cmisType12);
+
+ MutableTypeDefinition cmisType21;
+ cmisType21 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.1");
+ cmisType21.setDisplayName("My Type 7 Level 2");
+ cmisType21.setDescription("Builtin InMemory type definition MyDocType2.1");
+ typesList.add(cmisType21);
+
+ MutableTypeDefinition cmisType22;
+ cmisType22 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.2");
+ cmisType22.setDisplayName("My Type 8 Level 2");
+ cmisType22.setDescription("Builtin InMemory type definition MyDocType2.2");
+ typesList.add(cmisType22);
+
+ MutableTypeDefinition cmisType23;
+ cmisType23 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.3");
+ cmisType23.setDisplayName("My Type 9 Level 2");
+ cmisType23.setDescription("Builtin InMemory type definition MyDocType2.3");
+ typesList.add(cmisType23);
+
+ MutableTypeDefinition cmisType24;
+ cmisType24 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.4");
+ cmisType24.setDisplayName("My Type 10 Level 2");
+ cmisType24.setDescription("Builtin InMemory type definition MyDocType2.4");
+ typesList.add(cmisType24);
+
+ MutableTypeDefinition cmisType25;
+ cmisType25 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.5");
+ cmisType25.setDisplayName("My Type 11 Level 2");
+ cmisType25.setDescription("Builtin InMemory type definition MyDocType2.5");
+ typesList.add(cmisType25);
+
+ MutableTypeDefinition cmisType26;
+ cmisType26 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.6");
+ cmisType26.setDisplayName("My Type 12 Level 2");
+ cmisType26.setDescription("Builtin InMemory type definition MyDocType2.6");
+ typesList.add(cmisType26);
+
+ MutableTypeDefinition cmisType27;
+ cmisType27 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.7");
+ cmisType27.setDisplayName("My Type 13 Level 2");
+ cmisType27.setDescription("Builtin InMemory type definition MyDocType2.7");
+ typesList.add(cmisType27);
+
+ MutableTypeDefinition cmisType28;
+ cmisType28 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.8");
+ cmisType28.setDisplayName("My Type 14 Level 2");
+ cmisType28.setDescription("Builtin InMemory type definition MyDocType2.8");
+ typesList.add(cmisType28);
+
+ MutableTypeDefinition cmisType29;
+ cmisType29 = typeFactory.createChildTypeDefinition(cmisType2, "MyDocType2.9");
+ cmisType29.setDisplayName("My Type 15 Level 2");
+ cmisType29.setDescription("Builtin InMemory type definition MyDocType2.9");
+ typesList.add(cmisType29);
+
+ // create a complex type with properties
+ MutableDocumentTypeDefinition cmisComplexType;
+ cmisComplexType = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+ cmisComplexType.setId(COMPLEX_TYPE);
+ cmisComplexType.setDisplayName("Complex type with properties, Level 1");
+ cmisComplexType.setDescription("Builtin InMemory type definition ComplexType");
+
+ // create a boolean property definition
+
+ PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition(PROP_ID_BOOLEAN,
+ "Sample Boolean Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop);
+
+ prop = PropertyCreationHelper.createBooleanMultiDefinition(PROP_ID_BOOLEAN_MULTI_VALUE,
+ "Sample Boolean multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop);
+
+ PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition(PROP_ID_DATETIME,
+ "Sample DateTime Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop2);
+
+ prop2 = PropertyCreationHelper.createDateTimeMultiDefinition(PROP_ID_DATETIME_MULTI_VALUE,
+ "Sample DateTime multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop2);
+
+ PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition(PROP_ID_DECIMAL,
+ "Sample Decimal Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop3);
+
+ prop3 = PropertyCreationHelper.createDecimalMultiDefinition(PROP_ID_DECIMAL_MULTI_VALUE, "Sample Decimal multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop3);
+
+ PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition(PROP_ID_HTML,
+ "Sample Html Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop4);
+
+ prop4 = PropertyCreationHelper.createHtmlMultiDefinition(PROP_ID_HTML_MULTI_VALUE, "Sample Html multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop4);
+
+ PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition(PROP_ID_ID, "Sample Id Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop5);
+
+ prop5 = PropertyCreationHelper.createIdMultiDefinition(PROP_ID_ID_MULTI_VALUE, "Sample Id Html multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop5);
+
+ PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT,
+ "Sample Int Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop6);
+
+ prop6 = PropertyCreationHelper.createIntegerMultiDefinition(PROP_ID_INT_MULTI_VALUE, "Sample Int multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop6);
+
+ PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
+ "Sample String Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop7);
+
+ prop7 = PropertyCreationHelper.createStringMultiDefinition(PROP_ID_STRING_MULTI_VALUE,
+ "Sample String multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop7);
+
+ PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition(PROP_ID_URI, "Sample Uri Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop8);
+
+ prop8 = PropertyCreationHelper.createUriMultiDefinition(PROP_ID_URI_MULTI_VALUE, "Sample Uri multi-value Property", Updatability.READONLY);
+ cmisComplexType.addPropertyDefinition(prop8);
+
+ PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition("PickListProp",
+ "Sample Pick List Property", Updatability.READONLY);
+ List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+ ChoiceImpl<String> elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("red"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("green"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("blue"));
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("black"));
+ choiceList.add(elem);
+ prop9.setChoices(choiceList);
+ prop9.setDefaultValue(Collections.singletonList("blue"));
+ cmisComplexType.addPropertyDefinition(prop9);
+
+ // add type to types collection
+ typesList.add(cmisComplexType);
+
+ // create a type hierarchy with inherited properties
+ MutableDocumentTypeDefinition cmisDocTypeTopLevel;
+ cmisDocTypeTopLevel = typeFactory.createDocumentTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisDocumentType().getId());
+ cmisDocTypeTopLevel.setId(TOPLEVEL_TYPE);
+ cmisDocTypeTopLevel.setDisplayName("Document type with properties, Level 1");
+ cmisDocTypeTopLevel.setDescription("Builtin InMemory type definition " + TOPLEVEL_TYPE);
+
+ MutableTypeDefinition cmisDocTypeLevel1;
+ cmisDocTypeLevel1 = typeFactory.createChildTypeDefinition(cmisDocTypeTopLevel, LEVEL1_TYPE);
+ cmisDocTypeLevel1.setDisplayName("Document type with inherited properties, Level 2");
+ cmisDocTypeLevel1 .setDescription("Builtin InMemory type definition " + LEVEL1_TYPE);
+
+ MutableTypeDefinition cmisDocTypeLevel2;
+ cmisDocTypeLevel2 = typeFactory.createChildTypeDefinition(cmisDocTypeLevel1, LEVEL2_TYPE);
+ cmisDocTypeLevel2.setDisplayName("Document type with inherited properties, Level 3");
+ cmisDocTypeLevel2.setDescription("Builtin InMemory type definition " + LEVEL2_TYPE);
+
+ PropertyStringDefinitionImpl propTop = PropertyCreationHelper.createStringDefinition("StringPropTopLevel",
+ "Sample String Property", Updatability.READWRITE);
+ cmisDocTypeTopLevel.addPropertyDefinition(propTop);
+
+ PropertyStringDefinitionImpl propLevel1 = PropertyCreationHelper.createStringDefinition("StringPropLevel1",
+ "String Property Level 1", Updatability.READWRITE);
+ cmisDocTypeLevel1.addPropertyDefinition(propLevel1);
+
+ PropertyStringDefinitionImpl propLevel2 = PropertyCreationHelper.createStringDefinition("StringPropLevel2",
+ "String Property Level 2", Updatability.READWRITE);
+ cmisDocTypeLevel2.addPropertyDefinition(propLevel2);
+
+ // create a versioned type with properties
+ MutableDocumentTypeDefinition cmisVersionedType;
+ cmisVersionedType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), VERSIONED_TYPE);
+ cmisVersionedType.setDisplayName("Versioned Type");
+ cmisVersionedType.setDescription("Builtin InMemory type definition " + VERSIONED_TYPE);
+ cmisVersionedType.setIsVersionable(true); // make it a versionable type;
+
+ // create a single String property definition
+ PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(VERSION_PROPERTY_ID,
+ "Sample String Property", Updatability.WHENCHECKEDOUT);
+ cmisVersionedType.addPropertyDefinition(prop1);
+
+ // add type to types collection
+
+ // create a folder type
+ // create a complex type with properties
+ MutableFolderTypeDefinition cmisFolderType;
+ cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+ cmisFolderType.setId(FOLDER_TYPE);
+ cmisFolderType.setDisplayName("Folder type with properties");
+ cmisFolderType.setDescription("InMemory test type definition " + FOLDER_TYPE);
+
+ // create a two property definitions for folder
+ prop6 = PropertyCreationHelper.createIntegerDefinition(PROP_ID_INT, "Sample Folder Int Property", Updatability.READONLY);
+ cmisFolderType.addPropertyDefinition(prop6);
+
+ prop7 = PropertyCreationHelper.createStringDefinition(PROP_ID_STRING,
+ "Sample Folder String Property", Updatability.READONLY);
+ cmisFolderType.addPropertyDefinition(prop7);
+
+ // CMIS 1.1 create a secondary type
+ MutableSecondaryTypeDefinition cmisSecondaryType;
+ cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+ cmisSecondaryType.setId(SECONDARY_TYPE);
+ cmisSecondaryType.setDisplayName("MySecondaryType");
+ cmisSecondaryType.setDescription("Builtin InMemory type definition " + SECONDARY_TYPE);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType);
+ cmisSecondaryType.setIsFileable(false);
+
+ // create a single String property definition
+ PropertyStringDefinitionImpl propS1 = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
+ "Secondary String Property", Updatability.READWRITE);
+ cmisSecondaryType.addPropertyDefinition(propS1);
+ PropertyIntegerDefinitionImpl propS2 = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
+ "Secondary Integer Property", Updatability.READWRITE);
+ propS2.setIsRequired(true);
+ cmisSecondaryType.addPropertyDefinition(propS2);
+
+ MutableSecondaryTypeDefinition cmisSecondaryType2;
+ cmisSecondaryType2 = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+ cmisSecondaryType2.setId(SECONDARY_TYPE_2);
+ cmisSecondaryType2.setDisplayName("MySecondaryType-2");
+ cmisSecondaryType2.setDescription("Builtin InMemory type definition " + SECONDARY_TYPE_2);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType2);
+
+ // add type to types collectio
+ typesList.add(cmisDocTypeTopLevel);
+ typesList.add(cmisDocTypeLevel1);
+ typesList.add(cmisDocTypeLevel2);
+ typesList.add(cmisVersionedType);
+ typesList.add(cmisFolderType);
+ typesList.add(cmisSecondaryType);
+ typesList.add(cmisSecondaryType2);
+ return typesList;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersionTestTypeSystemCreator.java Thu Aug 8 08:40:26 2013
@@ -18,17 +18,17 @@
*/
package org.apache.chemistry.opencmis.inmemory;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
public class VersionTestTypeSystemCreator implements TypeCreator {
public static final String VERSION_TEST_DOCUMENT_TYPE_ID = "MyVersionedType";
@@ -63,28 +63,31 @@ public class VersionTestTypeSystemCreato
* @return typesMap map filled with created types
*/
private static List<TypeDefinition> buildTypesList() {
+ TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
// always add CMIS default types
List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
- // create a complex type with properties
- InMemoryDocumentTypeDefinition cmisComplexType = new InMemoryDocumentTypeDefinition(
- VERSION_TEST_DOCUMENT_TYPE_ID, "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a boolean property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID,
- "Sample String Property", Updatability.WHENCHECKEDOUT);
- propertyDefinitions.put(prop1.getId(), prop1);
-
- cmisComplexType.addCustomPropertyDefinitions(propertyDefinitions);
- cmisComplexType.setIsVersionable(true); // make it a versionable type;
-
- // add type to types collection
- typesList.add(cmisComplexType);
-
- return typesList;
+ try {
+ // create a complex type with properties
+ MutableDocumentTypeDefinition cmisComplexType;
+ cmisComplexType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), VERSION_TEST_DOCUMENT_TYPE_ID);
+ cmisComplexType.setDisplayName("VersionedType");
+ cmisComplexType.setDescription("InMemory test type definition " + VERSION_TEST_DOCUMENT_TYPE_ID);
+ cmisComplexType.setIsVersionable(true); // make it a versionable type;
+
+ // create a boolean property definition
+
+ PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID,
+ "Sample String Property", Updatability.WHENCHECKEDOUT);
+ cmisComplexType.addPropertyDefinition(prop1);
+
+ // add type to types collection
+ typesList.add(cmisComplexType);
+
+ return typesList;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating types.", e);
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/VersioningTest.java Thu Aug 8 08:40:26 2013
@@ -27,7 +27,6 @@ import static org.junit.Assert.fail;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -41,25 +40,19 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.PropertyId;
import org.apache.chemistry.opencmis.commons.data.PropertyString;
import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.Updatability;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
import org.apache.chemistry.opencmis.commons.server.CallContext;
import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class VersioningTest extends AbstractServiceTest {
private static final Logger log = LoggerFactory.getLogger(ObjectServiceTest.class);
@@ -515,10 +508,9 @@ public class VersioningTest extends Abst
assertNotNull(pdb);
boolean bVal = pdb.getFirstValue();
if (versioningState != VersioningState.CHECKEDOUT)
- assertTrue(bVal);
+ assertTrue(bVal);
else
- assertFalse(bVal);
-
+ assertFalse(bVal);
pdb = (PropertyBoolean) props.get(PropertyIds.IS_MAJOR_VERSION);
assertNotNull(pdb);
bVal = pdb.getFirstValue();
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/AbstractQueryTest.java Thu Aug 8 08:40:26 2013
@@ -21,21 +21,21 @@ package org.apache.chemistry.opencmis.in
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.antlr.runtime.RecognitionException;
+import org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyDateTimeDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
import org.apache.chemistry.opencmis.server.support.TypeManager;
import org.apache.chemistry.opencmis.server.support.query.CmisQueryWalker;
import org.apache.chemistry.opencmis.server.support.query.PredicateWalkerBase;
@@ -88,68 +88,72 @@ public abstract class AbstractQueryTest
// Helper to create some types for testing
protected List<TypeDefinition> createTypes() {
-
+ TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
List<TypeDefinition> typeDefs = new ArrayList<TypeDefinition>();
- // First test type
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE,
- "Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ try {
+ // First test type
+ MutableTypeDefinition cmisType;
+ cmisType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), MY_DOC_TYPE);
+ cmisType.setId(MY_DOC_TYPE);
+ cmisType.setDisplayName("Document Type for Validation");
- PropertyBooleanDefinition prop1 = PropertyCreationHelper.createBooleanDefinition(BOOL_PROP,
- "Sample Boolean Property", Updatability.READWRITE);
- ((PropertyBooleanDefinitionImpl) prop1).setIsRequired(true);
- propertyDefinitions.put(prop1.getId(), prop1);
+ PropertyBooleanDefinition prop1 = PropertyCreationHelper.createBooleanDefinition(BOOL_PROP,
+ "Sample Boolean Property", Updatability.READWRITE);
+ ((PropertyBooleanDefinitionImpl) prop1).setIsRequired(true);
- PropertyStringDefinition prop2 = PropertyCreationHelper.createStringDefinition(STRING_PROP,
- "Sample String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
+ PropertyStringDefinition prop2 = PropertyCreationHelper.createStringDefinition(STRING_PROP,
+ "Sample String Property", Updatability.READWRITE);
- PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(INT_PROP,
- "Sample Integer Property", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
+ PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(INT_PROP,
+ "Sample Integer Property", Updatability.READWRITE);
- cmisType.setPropertyDefinitions(propertyDefinitions);
+ cmisType.addPropertyDefinition(prop1);
+ cmisType.addPropertyDefinition(prop2);
+ cmisType.addPropertyDefinition(prop3);
- typeDefs.add(cmisType);
- myType = cmisType;
+ typeDefs.add(cmisType);
+ myType = cmisType;
- // add another type definition with exactly the same properties
- cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE_COPY,
- "Document Type Duplicated", InMemoryDocumentTypeDefinition.getRootDocumentType());
- cmisType.setPropertyDefinitions(propertyDefinitions); // add same properties
- typeDefs.add(cmisType);
- myTypeCopy = cmisType;
+ // add another type definition with exactly the same properties
+ cmisType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), MY_DOC_TYPE_COPY);
+ cmisType.setDisplayName("Document Type for Duplicated");
+ // add same properties
+ cmisType.addPropertyDefinition(prop1);
+ cmisType.addPropertyDefinition(prop2);
+ cmisType.addPropertyDefinition(prop3);
+ typeDefs.add(cmisType);
+ myTypeCopy = cmisType;
- // Second test type
- cmisType = new InMemoryDocumentTypeDefinition(BOOK_TYPE,
- "Book Document Type", InMemoryDocumentTypeDefinition.getRootDocumentType());
+ // Second test type
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ cmisType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), BOOK_TYPE);
+ cmisType.setDisplayName("Book Document Type");
- prop2 = PropertyCreationHelper.createStringDefinition(TITLE_PROP, "Title of Book", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
- prop2 = PropertyCreationHelper.createStringDefinition(AUTHOR_PROP, "Author of Book", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
+ prop2 = PropertyCreationHelper.createStringDefinition(TITLE_PROP, "Title of Book", Updatability.READWRITE);
+ cmisType.addPropertyDefinition(prop2);
- prop3 = PropertyCreationHelper.createIntegerDefinition(ISBN_PROP,
- "ISBN of Book", Updatability.READWRITE);
- propertyDefinitions.put(prop3.getId(), prop3);
+ prop2 = PropertyCreationHelper.createStringDefinition(AUTHOR_PROP, "Author of Book", Updatability.READWRITE);
+ cmisType.addPropertyDefinition(prop2);
- PropertyDateTimeDefinitionImpl prop4 = PropertyCreationHelper.createDateTimeDefinition(PUB_DATE_PROP,
- "Publishing Date of Book", Updatability.READWRITE);
- propertyDefinitions.put(prop4.getId(), prop4);
+ prop3 = PropertyCreationHelper.createIntegerDefinition(ISBN_PROP,
+ "ISBN of Book", Updatability.READWRITE);
+ cmisType.addPropertyDefinition(prop3);
- cmisType.setPropertyDefinitions(propertyDefinitions);
+ PropertyDateTimeDefinitionImpl prop4 = PropertyCreationHelper.createDateTimeDefinition(PUB_DATE_PROP,
+ "Publishing Date of Book", Updatability.READWRITE);
+ cmisType.addPropertyDefinition(prop4);
- typeDefs.add(cmisType);
- bookType = cmisType;
+ typeDefs.add(cmisType);
+ bookType = cmisType;
- return typeDefs;
+ return typeDefs;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/EvalQueryTest.java Thu Aug 8 08:40:26 2013
@@ -903,13 +903,13 @@ public class EvalQueryTest extends Abstr
assertEquals(2, res.getObjects().size());
assertTrue(resultContains("ver123", UnitTestTypeSystemCreator.VERSION_PROPERTY_ID, res));
assertTrue(resultContains("ver456", UnitTestTypeSystemCreator.VERSION_PROPERTY_ID, res));
- assertTrue(resultContains("V 1.0", PropertyIds.VERSION_LABEL, res));
- assertTrue(resultContains("V 2.0", PropertyIds.VERSION_LABEL, res));
+ assertTrue(resultContains("1.0", PropertyIds.VERSION_LABEL, res));
+ assertTrue(resultContains("2.0", PropertyIds.VERSION_LABEL, res));
res = doQuery(statement);
assertEquals(1, res.getObjects().size());
- assertFalse(resultContains("V 1.0", PropertyIds.VERSION_LABEL, res));
- assertTrue(resultContains("V 2.0", PropertyIds.VERSION_LABEL, res));
+ assertFalse(resultContains("1.0", PropertyIds.VERSION_LABEL, res));
+ assertTrue(resultContains("2.0", PropertyIds.VERSION_LABEL, res));
log.debug("...Stop testLastestVersionsWithQuery.");
}
@@ -922,12 +922,12 @@ public class EvalQueryTest extends Abstr
ObjectList res = doQuery(statement);
assertEquals(1, res.getObjects().size());
assertTrue(resultContains("ver456", UnitTestTypeSystemCreator.VERSION_PROPERTY_ID, res));
- assertTrue(resultContains("V 2.0", PropertyIds.VERSION_LABEL, res));
+ assertTrue(resultContains("2.0", PropertyIds.VERSION_LABEL, res));
res = doQuery(statement);
assertEquals(1, res.getObjects().size());
- assertFalse(resultContains("V 1.0", PropertyIds.VERSION_LABEL, res));
- assertTrue(resultContains("V 2.0", PropertyIds.VERSION_LABEL, res));
+ assertFalse(resultContains("1.0", PropertyIds.VERSION_LABEL, res));
+ assertTrue(resultContains("2.0", PropertyIds.VERSION_LABEL, res));
log.debug("...Stop testLastestVersionsWithQuery.");
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ProcessQueryTest.java Thu Aug 8 08:40:26 2013
@@ -414,12 +414,12 @@ public class ProcessQueryTest extends Ab
@Before
public void setUp() {
tm = new TypeManagerImpl();
- tm.initTypeSystem(null); // create CMIS default types
+ tm.initTypeSystem(null, true); // create CMIS default types
// create some types for testing
List<TypeDefinition> typeDefs = super.createTypes();
for (TypeDefinition typeDef : typeDefs) {
- tm.addTypeDefinition(typeDef);
+ tm.addTypeDefinition(typeDef, true);
}
// initialize query object with type manager
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryTypesTest.java Thu Aug 8 08:40:26 2013
@@ -63,12 +63,12 @@ public class QueryTypesTest extends Abst
@Before
public void setUp() {
tm = new TypeManagerImpl();
- tm.initTypeSystem(null); // create CMIS default types
+ tm.initTypeSystem(null, true); // create CMIS default types
// create some types for testing
List<TypeDefinition> typeDefs = super.createTypes();
for (TypeDefinition typeDef : typeDefs) {
- tm.addTypeDefinition(typeDef);
+ tm.addTypeDefinition(typeDef, true);
}
// initialize query object with type manager
@@ -533,12 +533,12 @@ public class QueryTypesTest extends Abst
public void testSecondaryJoin() throws RecognitionException {
// needs some special types:
tm = new TypeManagerImpl();
- tm.initTypeSystem(null); // create CMIS default types
+ tm.initTypeSystem(null, true); // create CMIS default types
// create some types for testing
List<TypeDefinition> typeDefs = UnitTestTypeSystemCreator.getTypesList();
for (TypeDefinition typeDef : typeDefs) {
- tm.addTypeDefinition(typeDef);
+ tm.addTypeDefinition(typeDef, true);
}
super.setUp(tm, pw);