This project has retired. For details please refer to its
Attic page.
InMemoryRelationshipTypeDefinition 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 */1920package org.apache.chemistry.opencmis.inmemory.types;
2122import java.util.HashMap;
23import java.util.Map;
2425import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
26import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
27import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
28import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
29import org.apache.chemistry.opencmis.inmemory.NameValidator;
3031publicclassInMemoryRelationshipTypeDefinitionextends RelationshipTypeDefinitionImpl {
3233privatestaticfinallong serialVersionUID = 1L;
34privatestaticfinalInMemoryRelationshipTypeDefinition RELATIONSHIP_TYPE = newInMemoryRelationshipTypeDefinition();
3536publicstaticInMemoryRelationshipTypeDefinition getRootRelationshipType() {
37return RELATIONSHIP_TYPE;
38 }
3940/* This constructor is just for creating the root document */41publicInMemoryRelationshipTypeDefinition() {
42 init(BaseTypeId.CMIS_RELATIONSHIP.value(), "CMIS Relation");
43 setParentTypeId(null);
4445 Map<String, PropertyDefinition<?>> props = getPropertyDefinitions();
46 DocumentTypeCreationHelper.setBasicRelationshipPropertyDefinitions(props);
47 }
4849publicInMemoryRelationshipTypeDefinition(String id, String displayName) {
50 init(id, displayName);
51 setParentTypeId(RELATIONSHIP_TYPE.getId());
52 }
5354publicInMemoryRelationshipTypeDefinition(String id, String displayName,
55InMemoryRelationshipTypeDefinition parentType) {
56// get root type57 init(id, displayName);
58if (parentType != null) {
59 setBaseTypeId(parentType.getBaseTypeId());
60 } else {
61thrownew IllegalArgumentException("Must provide a parent type when creating a relationship definition");
62 }
63 setParentTypeId(parentType.getId());
64 }
6566/*67 * Set the property definitions for this type. The parameter68 * propertyDefinitions should only contain the custom property definitions69 * for this type. The standard property definitions are added automatically.70 *71 * @seeorg.apache.opencmis.commons.impl.dataobjects.AbstractTypeDefinition#72 * setPropertyDefinitions(java.util.Map)73 */74publicvoid addCustomPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
75 DocumentTypeCreationHelper.mergePropertyDefinitions(getPropertyDefinitions(), propertyDefinitions);
76 }
7778privatevoid init(String id, String displayName) {
79if (!NameValidator.isValidId(id)) {
80thrownew CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
81 }
8283 setBaseTypeId(BaseTypeId.CMIS_RELATIONSHIP);
84 setId(id);
85if (displayName == null) {
86 displayName = id;
87 }
88 setDisplayName(displayName);
89// create some suitable defaults for convenience90 setDescription("Description of " + getDisplayName() + " Type");
91 setLocalName(id);
92 setLocalNamespace("local");
93 setQueryName(id);
94 setIsControllableAcl(false);
95 setIsControllablePolicy(false);
96 setIsCreatable(true);
97 setIsFileable(true);
98 setIsFulltextIndexed(false);
99 setIsIncludedInSupertypeQuery(true);
100 setIsQueryable(false);
101102// TODO: add with CMIS 1.1 extensions103// TypeMutabilityCapabilitiesImpl caps = new TypeMutabilityCapabilitiesImpl();104// caps.setSupportsCreate(createAndDeletable);105// caps.setSupportsUpdate(false);106// caps.setSupportsDelete(createAndDeletable);107// super.setTypeMutability(caps);108109// relationship specifics110 setAllowedSourceTypes(null);
111 setAllowedTargetTypes(null);
112113// set base properties114 Map<String, PropertyDefinition<?>> props = new HashMap<String, PropertyDefinition<?>>();
115 setPropertyDefinitions(props); // set initial empty set of properties116 }
117118 }