org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.dataobjects.TypeDefinitionContainerImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gathers the type descendants tree
 * 
 * @param depth depth specifications
 * @param tc the container
 * @param includePropertyDefinitions if the property definitions must be included
 * 
 * @return the definition container
 */
private TypeDefinitionContainer getTypesDescendants(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(getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
			}
		}
	}

	return result;
}
 
Example #2
Source File: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a type container list
 * 
 * @param typeContainers the container that specifies the types
 * 
 * @return the list of type definitions
 */
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;
}
 
Example #3
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds a type to collection.
 */
private void addTypeInteral(AbstractTypeDefinition type) {
	if (type == null) {
		return;
	}

	if (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 = types.get(type.getParentTypeId());
		if (tdc != null) {
			if (tdc.getChildren() == null) {
				tdc.setChildren(new ArrayList<TypeDefinitionContainer>());
			}
			tdc.getChildren().add(tc);
		}
	}

	types.put(type.getId(), tc);
	typesList.add(tc);
}
 
Example #5
Source File: CmisUtils.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static List<TypeDefinitionContainer> xml2TypeDescendants(Element typeDefinitionsXml, CmisVersion cmisVersion) {
	List<TypeDefinitionContainer> typeDefinitionList = new ArrayList<TypeDefinitionContainer>();
	Collection<Node> typeDescendantList = XmlUtils.getChildTags(typeDefinitionsXml, "typeDescendant");
	for (Node node : typeDescendantList) {
		Element typeDefinition = XmlUtils.getFirstChildTag((Element) node, "typeDefinition");
		TypeDefinition typeDef = CmisUtils.xml2TypeDefinition(typeDefinition, cmisVersion);
		TypeDefinitionContainerImpl typeDefinitionContainer = new TypeDefinitionContainerImpl(typeDef);

		Element children = XmlUtils.getFirstChildTag((Element) node, "children");
		typeDefinitionContainer.setChildren(xml2TypeDescendants(children, cmisVersion));

		typeDefinitionList.add(typeDefinitionContainer);
	}
	return typeDefinitionList;
}