/** * 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); }
public TypeDefinition getTypeByQueryName(String typeQueryName) { for (TypeDefinitionContainerImpl type : fTypes.values()) { TypeDefinition typeDef = type.getTypeDefinition(); if (typeDef.getQueryName().equals(typeQueryName)) { return typeDef; } } return null; }
/** * Creates a type definition container. * * @param typeDef * the type definition, not {@code null} * @param children * the child type definitions, may be {@code null} * * @return the TypeDefinitionContainer object */ public TypeDefinitionContainer createTypeDefinitionContainer(TypeDefinition typeDef, List<TypeDefinitionContainer> children) { if (typeDef == null) { throw new IllegalArgumentException("Type definition must be set!"); } TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(typeDef); result.setChildren(children); return result; }
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; }
/** * Converts a type container list. */ public static List<TypeDefinitionContainer> convertTypeContainerList(List<CmisTypeContainer> typeContainers) { if (typeContainers == null) { return null; } List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); for (CmisTypeContainer container : typeContainers) { TypeDefinitionContainerImpl newConatiner = new TypeDefinitionContainerImpl(); newConatiner.setTypeDefinition(convert(container.getType())); newConatiner.setChildren(convertTypeContainerList(container.getChildren())); convertExtension(container, newConatiner); result.add(newConatiner); } return result; }
/** * Helper method for * {@link #getTypeDescendants(String, String, BigInteger, Boolean, ExtensionsData)} * . */ private void addTypeChildren(String repositoryId, Boolean includePropertyDefinitions, int depth, TypeDefinitionContainerImpl container) { if (depth == 0) { return; } TypeDefinitionList children = getTypeChildren(repositoryId, container.getTypeDefinition().getId(), includePropertyDefinitions, BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.ZERO, null); if (children != null && isNotEmpty(children.getList())) { List<TypeDefinitionContainer> list = new ArrayList<TypeDefinitionContainer>(); container.setChildren(list); for (TypeDefinition td : children.getList()) { TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td); addTypeChildren(repositoryId, includePropertyDefinitions, (depth > 0 ? depth - 1 : -1), tdc); list.add(tdc); } } }
TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td); addTypeChildren(repositoryId, includePropertyDefinitions, (d > 0 ? d - 1 : -1), tdc); result.add(tdc);
/** * Converts a type definition list. */ @SuppressWarnings({ "unchecked" }) public static List<TypeDefinitionContainer> convertTypeDescendants(final List<Object> json) { if (json == null) { return null; } if (json.isEmpty()) { return Collections.emptyList(); } List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); for (Object obj : json) { if (obj instanceof Map) { Map<String, Object> jsonContainer = (Map<String, Object>) obj; TypeDefinitionContainerImpl container = new TypeDefinitionContainerImpl(); container.setTypeDefinition(convertTypeDefinition(getMap(jsonContainer.get(JSON_TYPESCONTAINER_TYPE)))); Object children = jsonContainer.get(JSON_TYPESCONTAINER_CHILDREN); if (children instanceof List) { container.setChildren(convertTypeDescendants((List<Object>) children)); } else { container.setChildren(Collections.<TypeDefinitionContainer> emptyList()); } convertExtension(jsonContainer, container, TYPESCONTAINER_KEYS); result.add(container); } } return result; }
/** * Helper method for * {@link #getTypeDescendants(String, String, BigInteger, Boolean, ExtensionsData)} * . */ private void addTypeChildren(String repositoryId, Boolean includePropertyDefinitions, int depth, TypeDefinitionContainerImpl container) { if (depth == 0) { return; } TypeDefinitionList children = getTypeChildren(repositoryId, container.getTypeDefinition().getId(), includePropertyDefinitions, BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.ZERO, null); if (children != null && isNotEmpty(children.getList())) { List<TypeDefinitionContainer> list = new ArrayList<TypeDefinitionContainer>(); container.setChildren(list); for (TypeDefinition td : children.getList()) { TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td); addTypeChildren(repositoryId, includePropertyDefinitions, (depth > 0 ? depth - 1 : -1), tdc); list.add(tdc); } } }
addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject()); } else if (element.getObject() instanceof TypeDefinition) { childContainer = new TypeDefinitionContainerImpl((TypeDefinition) element.getObject()); } else if (element.getObject() instanceof AtomFeed) { addTypeDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList); childContainer.setChildren(childContainerList); containerList.add(childContainer);
TypeDefinitionContainerImpl tdc = new TypeDefinitionContainerImpl(td); addTypeChildren(repositoryId, includePropertyDefinitions, (d > 0 ? d - 1 : -1), tdc); result.add(tdc);
/** * 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); }
/** * Converts a type definition list. */ @SuppressWarnings({ "unchecked" }) public static List<TypeDefinitionContainer> convertTypeDescendants(final List<Object> json) { if (json == null) { return null; } if (json.isEmpty()) { return Collections.emptyList(); } List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); for (Object obj : json) { if (obj instanceof Map) { Map<String, Object> jsonContainer = (Map<String, Object>) obj; TypeDefinitionContainerImpl container = new TypeDefinitionContainerImpl(); container.setTypeDefinition(convertTypeDefinition(getMap(jsonContainer.get(JSON_TYPESCONTAINER_TYPE)))); Object children = jsonContainer.get(JSON_TYPESCONTAINER_CHILDREN); if (children instanceof List) { container.setChildren(convertTypeDescendants((List<Object>) children)); } else { container.setChildren(Collections.<TypeDefinitionContainer> emptyList()); } convertExtension(jsonContainer, container, TYPESCONTAINER_KEYS); result.add(container); } } return result; }
addTypeLink(repositoryId, entry.getId(), (AtomLink) element.getObject()); } else if (element.getObject() instanceof TypeDefinition) { childContainer = new TypeDefinitionContainerImpl((TypeDefinition) element.getObject()); } else if (element.getObject() instanceof AtomFeed) { addTypeDescendantsLevel(repositoryId, (AtomFeed) element.getObject(), childContainerList); childContainer.setChildren(childContainerList); containerList.add(childContainer);
baseType = copyTypeDefintion(m_types.get(DOCUMENT_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { baseType = copyTypeDefintion(m_types.get(FOLDER_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) { baseType = copyTypeDefintion(m_types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) { baseType = copyTypeDefintion(m_types.get(POLICY_TYPE_ID).getTypeDefinition()); } else { return false;
/** * 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; }
baseType = copyTypeDefinition(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition()); baseType = copyTypeDefinition(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition()); baseType = copyTypeDefinition(fTypes.get(RELATIONSHIP_TYPE_ID).getTypeDefinition()); baseType = copyTypeDefinition(fTypes.get(POLICY_TYPE_ID).getTypeDefinition());
/** * 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; }
result.getList().add(copyTypeDefinition(fTypes.get(FOLDER_TYPE_ID).getTypeDefinition())); max--; result.getList().add(copyTypeDefinition(fTypes.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
/** * 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; }