/** * Adds a type to collection. */ private void addTypeInternal(AbstractTypeDefinition type) { if (type == null) { return; } TypeDefinitionContainerImpl tc = new TypeDefinitionContainerImpl(); tc.setTypeDefinition(type); // add to parent if (type.getParentTypeId() != null) { TypeDefinitionContainerImpl tdc = fTypes.get(type.getParentTypeId()); if (tdc != null) { if (tdc.getChildren() == null) { tdc.setChildren(new ArrayList<TypeDefinitionContainer>()); } tdc.getChildren().add(tc); } } fTypes.put(type.getId(), tc); }
private TypeDefinitionContainer createTypeDefinitionContainer(Map<String, TypeDefinition> allTypes, Map<String, Set<String>> typeDefChildren, String typeId, int depth, boolean includePropertyDefinitions, CmisVersion cmisVersion) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); result.setTypeDefinition(includePropertyDefinitions ? copy(allTypes.get(typeId), true, cmisVersion) : copy( allTypes.get(typeId), false, cmisVersion)); if (depth != 0) { if (typeDefChildren.containsKey(typeId)) { for (String child : typeDefChildren.get(typeId)) { result.getChildren().add( createTypeDefinitionContainer(allTypes, typeDefChildren, child, depth < 0 ? -1 : depth - 1, includePropertyDefinitions, cmisVersion)); } } } return result; }
/** * Internal method which adds a new type, without adding any property definitions automatically.<p> * * @param type the type to add */ private void addTypeInternal(AbstractTypeDefinition type) { if (type == null) { return; } if (m_types.containsKey(type.getId())) { // can't overwrite a type return; } TypeDefinitionContainerImpl tc = new TypeDefinitionContainerImpl(); tc.setTypeDefinition(type); // add to parent if (type.getParentTypeId() != null) { TypeDefinitionContainerImpl tdc = m_types.get(type.getParentTypeId()); if (tdc != null) { if (tdc.getChildren() == null) { tdc.setChildren(new ArrayList<TypeDefinitionContainer>()); } tdc.getChildren().add(tc); } } m_types.put(type.getId(), tc); m_typeList.add(tc); }
/** * Gathers the type descendants tree. */ private static TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionContainer tc, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); TypeDefinition type = copyTypeDefinition(tc.getTypeDefinition()); if (!includePropertyDefinitions) { type.getPropertyDefinitions().clear(); } result.setTypeDefinition(type); if (depth != 0) { if (tc.getChildren() != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionContainer tdc : tc.getChildren()) { result.getChildren().add( getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }
/** * Gathers the type descendants tree. */ private TypeDefinitionContainer getTypesDescendants( int depth, TypeDefinitionWrapper tdw, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); result.setTypeDefinition(tdw.getTypeDefinition(includePropertyDefinitions)); if (depth != 0) { String typeId = tdw.getTypeId(); List<TypeDefinitionWrapper> children = connector.getOpenCMISDictionaryService().getChildren(typeId); if (children != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionWrapper tdc : children) { result.getChildren().add( getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }
/** * Collects the descendants of a type.<p> * * @param depth the depth up to which the descendants should be collected * @param tc the parent type * @param includePropertyDefinitions true if the property definitions should be included * * @return the descendants of the type */ private TypeDefinitionContainer getTypeDescendants( int depth, TypeDefinitionContainer tc, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); TypeDefinition type = copyTypeDefintion(tc.getTypeDefinition()); if (!includePropertyDefinitions) { type.getPropertyDefinitions().clear(); } result.setTypeDefinition(type); if (depth != 0) { if (tc.getChildren() != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionContainer tdc : tc.getChildren()) { result.getChildren().add( getTypeDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }
/** * Gathers the type descendants tree. */ private TypeDefinitionContainer getTypesDescendants( int depth, TypeDefinitionWrapper tdw, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); result.setTypeDefinition(tdw.getTypeDefinition(includePropertyDefinitions)); if (depth != 0) { String typeId = tdw.getTypeId(); List<TypeDefinitionWrapper> children = connector.getOpenCMISDictionaryService().getChildren(typeId); if (children != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionWrapper tdc : children) { result.getChildren().add( getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }