Java Code Examples for org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer#getChildren()

The following examples show how to use org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer#getChildren() . 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: CmisTypeManager.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gathers the type descendants tree.
 */
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 3
Source File: TypeManager.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * CMIS getTypesChildren
 * 
 * @param context the call context
 * @param typeId identifier of the type
 * @param includePropertyDefinitions if the property definition must be
 *        included
 * @param maxItems maximum number of items
 * @param skipCount if the counting of children must be avoided
 * 
 * @return list of definitions
 */
public TypeDefinitionList getTypesChildren(CallContext context, String typeId, boolean includePropertyDefinitions,
		BigInteger maxItems, BigInteger skipCount) {
	TypeDefinitionListImpl result = new TypeDefinitionListImpl(new ArrayList<TypeDefinition>());

	int skip = (skipCount == null ? 0 : skipCount.intValue());
	if (skip < 0) {
		skip = 0;
	}

	int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
	if (max < 1) {
		return result;
	}

	if (typeId == null) {
		if (skip < 1) {
			result.getList().add(copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()));
			max--;
		}
		if ((skip < 2) && (max > 0)) {
			result.getList().add(copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
			max--;
		}

		result.setHasMoreItems((result.getList().size() + skip) < 2);
		result.setNumItems(BigInteger.valueOf(2));
	} else {
		TypeDefinitionContainer tc = types.get(typeId);
		if ((tc == null) || (tc.getChildren() == null)) {
			return result;
		}

		for (TypeDefinitionContainer child : tc.getChildren()) {
			if (skip > 0) {
				skip--;
				continue;
			}

			result.getList().add(copyTypeDefintion(child.getTypeDefinition()));

			max--;
			if (max == 0) {
				break;
			}
		}

		result.setHasMoreItems((result.getList().size() + skip) < tc.getChildren().size());
		result.setNumItems(BigInteger.valueOf(tc.getChildren().size()));
	}

	if (!includePropertyDefinitions) {
		for (TypeDefinition type : result.getList()) {
			type.getPropertyDefinitions().clear();
		}
	}

	return result;
}
 
Example 4
Source File: CmisTypeManager.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * CMIS getTypesChildren.
 */
public TypeDefinitionList getTypesChildren(CallContext context, String typeId, boolean includePropertyDefinitions, BigInteger maxItems,
                                           BigInteger skipCount) {
	TypeDefinitionListImpl result = new TypeDefinitionListImpl(new ArrayList<TypeDefinition>());

	int skip = (skipCount == null ? 0 : skipCount.intValue());
	if (skip < 0) {
		skip = 0;
	}

	int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue());
	if (max < 1) {
		return result;
	}

	if (typeId == null) {
		if (skip < 1) {
			result.getList().add(copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()));
			max--;
		}

		if ((skip < 2) && (max > 0)) {
			result.getList().add(copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()));
			max--;
		}

		result.setHasMoreItems((result.getList().size() + skip) < 2);
		result.setNumItems(BigInteger.valueOf(2));
	} else {
		TypeDefinitionContainer tc = types.get(typeId);

		if ((tc == null) || (tc.getChildren() == null)) {
			return result;
		}

		for (TypeDefinitionContainer child : tc.getChildren()) {
			if (skip > 0) {
				skip--;
				continue;
			}

			result.getList().add(copyTypeDefintion(child.getTypeDefinition()));

			max--;
			if (max == 0) {
				break;
			}
		}

		result.setHasMoreItems((result.getList().size() + skip) < tc.getChildren().size());
		result.setNumItems(BigInteger.valueOf(tc.getChildren().size()));
	}

	if (!includePropertyDefinitions) {
		for (TypeDefinition type : result.getList()) {
			type.getPropertyDefinitions().clear();
		}
	}

	return result;
}