Search in sources :

Example 1 with CMISObjectInFolderWrapper

use of org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper in project structr by structr.

the class CMISNavigationService method getChildren.

@Override
public ObjectInFolderList getChildren(final String repositoryId, final String folderId, final String propertyFilter, final String orderBy, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePathSegment, final BigInteger maxItems, final BigInteger skipCount, final ExtensionsData extension) {
    final App app = StructrApp.getInstance();
    final CMISObjectInFolderWrapper wrapper = new CMISObjectInFolderWrapper(propertyFilter, includeAllowableActions, maxItems, skipCount);
    try (final Tx tx = app.tx()) {
        wrapper.wrap(getChildrenQuery(app, folderId).getAsList());
        tx.success();
    } catch (final FrameworkException fex) {
        logger.warn("", fex);
    }
    return wrapper;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) CMISObjectInFolderWrapper(org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper)

Example 2 with CMISObjectInFolderWrapper

use of org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper in project structr by structr.

the class CMISNavigationService method recursivelyCollectFolderTree.

// ----- private methods -----
private void recursivelyCollectFolderTree(final List<ObjectInFolderContainer> list, final Folder child, final int maxDepth, final int depth, final Boolean includeAllowableActions) throws FrameworkException {
    if (depth > maxDepth) {
        return;
    }
    final CMISObjectInFolderWrapper wrapper = new CMISObjectInFolderWrapper(includeAllowableActions);
    final ObjectInFolderContainerImpl impl = new ObjectInFolderContainerImpl();
    final List<ObjectInFolderContainer> childContainerList = new LinkedList<>();
    final String pathSegment = child.getName();
    impl.setObject(wrapper.wrapObjectData(wrapper.wrapGraphObject(child), pathSegment));
    impl.setChildren(childContainerList);
    // add wrapped object to current list
    list.add(impl);
    // fetch and sort children
    final List<Folder> children = Iterables.toList(child.getFolders());
    Collections.sort(children, new GraphObjectComparator(AbstractNode.name, false));
    // descend into children
    for (final Folder folderChild : children) {
        recursivelyCollectFolderTree(childContainerList, folderChild, maxDepth, depth + 1, includeAllowableActions);
    }
}
Also used : ObjectInFolderContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl) CMISObjectInFolderWrapper(org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper) GraphObjectComparator(org.structr.common.GraphObjectComparator) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) LinkedList(java.util.LinkedList)

Example 3 with CMISObjectInFolderWrapper

use of org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper in project structr by structr.

the class CMISNavigationService method recursivelyCollectDescendants.

private void recursivelyCollectDescendants(final List<ObjectInFolderContainer> list, final AbstractFile child, final int maxDepth, final int depth, final Boolean includeAllowableActions) throws FrameworkException {
    if (depth > maxDepth) {
        return;
    }
    final PropertyKey<Folder> parent = StructrApp.key(AbstractFile.class, "parent");
    final PropertyKey<Boolean> hasParent = StructrApp.key(AbstractFile.class, "hasParent");
    final PropertyKey<Boolean> isThumbnail = StructrApp.key(Image.class, "isThumbnail");
    final CMISObjectInFolderWrapper wrapper = new CMISObjectInFolderWrapper(includeAllowableActions);
    final ObjectInFolderContainerImpl impl = new ObjectInFolderContainerImpl();
    final List<ObjectInFolderContainer> childContainerList = new LinkedList<>();
    final String pathSegment = child.getName();
    impl.setObject(wrapper.wrapObjectData(wrapper.wrapGraphObject(child), pathSegment));
    impl.setChildren(childContainerList);
    // add wrapped object to current list
    list.add(impl);
    if (child.getProperty(AbstractNode.type).equals("Folder")) {
        final App app = StructrApp.getInstance();
        // descend into children
        for (final AbstractFile folderChild : app.nodeQuery(AbstractFile.class).sort(AbstractNode.name).and(parent, (Folder) child).and(isThumbnail, false).getAsList()) {
            recursivelyCollectDescendants(childContainerList, folderChild, maxDepth, depth + 1, includeAllowableActions);
        }
    }
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) AbstractFile(org.structr.web.entity.AbstractFile) ObjectInFolderContainerImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl) CMISObjectInFolderWrapper(org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) LinkedList(java.util.LinkedList)

Aggregations

CMISObjectInFolderWrapper (org.structr.files.cmis.wrapper.CMISObjectInFolderWrapper)3 LinkedList (java.util.LinkedList)2 ObjectInFolderContainer (org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)2 ObjectInFolderContainerImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectInFolderContainerImpl)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 CMISRootFolder (org.structr.files.cmis.repository.CMISRootFolder)2 Folder (org.structr.web.entity.Folder)2 GraphObjectComparator (org.structr.common.GraphObjectComparator)1 FrameworkException (org.structr.common.error.FrameworkException)1 Tx (org.structr.core.graph.Tx)1 AbstractFile (org.structr.web.entity.AbstractFile)1