Search in sources :

Example 1 with NodeCommitQueryResult

use of com.enonic.xp.node.NodeCommitQueryResult in project xp by enonic.

the class NodeCommitQueryResultFactory method create.

public static NodeCommitQueryResult create(final NodeCommitQuery query, final SearchResult searchResult) {
    final NodeCommitQueryResult.Builder nodeCommitQueryResult = NodeCommitQueryResult.create();
    nodeCommitQueryResult.hits(searchResult.getHits().getSize());
    nodeCommitQueryResult.totalHits(searchResult.getTotalHits());
    nodeCommitQueryResult.from(query.getFrom());
    nodeCommitQueryResult.to(query.getSize());
    final NodeCommitEntries nodeCommitEntries = buildNodeCommitEntries(query, searchResult);
    nodeCommitQueryResult.nodeCommitEntries(nodeCommitEntries);
    return nodeCommitQueryResult.build();
}
Also used : NodeCommitEntries(com.enonic.xp.node.NodeCommitEntries) NodeCommitQueryResult(com.enonic.xp.node.NodeCommitQueryResult)

Example 2 with NodeCommitQueryResult

use of com.enonic.xp.node.NodeCommitQueryResult in project xp by enonic.

the class DumpServiceImplTest method checkCommitUpgrade.

private void checkCommitUpgrade(final NodeId nodeId) {
    nodeService.refresh(RefreshMode.ALL);
    final NodeCommitQuery nodeCommitQuery = NodeCommitQuery.create().build();
    final NodeCommitQueryResult nodeCommitQueryResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("master")).build().callWith(() -> nodeService.findCommits(nodeCommitQuery));
    assertEquals(1, nodeCommitQueryResult.getTotalHits());
    final NodeCommitEntry commitEntry = nodeCommitQueryResult.getNodeCommitEntries().iterator().next();
    final NodeCommitId nodeCommitId = commitEntry.getNodeCommitId();
    assertEquals("Dump upgrade", commitEntry.getMessage());
    assertEquals("user:system:node-su", commitEntry.getCommitter().toString());
    final GetActiveNodeVersionsParams activeNodeVersionsParams = GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(Branches.from(ContentConstants.BRANCH_DRAFT, ContentConstants.BRANCH_MASTER)).build();
    final GetActiveNodeVersionsResult activeNodeVersionsResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("master")).build().callWith(() -> nodeService.getActiveVersions(activeNodeVersionsParams));
    final NodeVersionMetadata draftNodeVersion = activeNodeVersionsResult.getNodeVersions().get(ContentConstants.BRANCH_DRAFT);
    assertNull(draftNodeVersion.getNodeCommitId());
    final NodeVersionMetadata masterNodeVersion = activeNodeVersionsResult.getNodeVersions().get(ContentConstants.BRANCH_MASTER);
    assertEquals(nodeCommitId, masterNodeVersion.getNodeCommitId());
    final NodeVersionQuery nodeVersionQuery = NodeVersionQuery.create().nodeId(nodeId).build();
    final NodeVersionQueryResult versionQueryResult = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("draft")).build().callWith(() -> nodeService.findVersions(nodeVersionQuery));
    assertEquals(16, versionQueryResult.getTotalHits());
}
Also used : NodeVersionQuery(com.enonic.xp.node.NodeVersionQuery) NodeCommitQuery(com.enonic.xp.node.NodeCommitQuery) GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) NodeCommitQueryResult(com.enonic.xp.node.NodeCommitQueryResult) NodeCommitId(com.enonic.xp.node.NodeCommitId) NodeVersionQueryResult(com.enonic.xp.node.NodeVersionQueryResult) GetActiveNodeVersionsParams(com.enonic.xp.node.GetActiveNodeVersionsParams)

Aggregations

NodeCommitQueryResult (com.enonic.xp.node.NodeCommitQueryResult)2 GetActiveNodeVersionsParams (com.enonic.xp.node.GetActiveNodeVersionsParams)1 GetActiveNodeVersionsResult (com.enonic.xp.node.GetActiveNodeVersionsResult)1 NodeCommitEntries (com.enonic.xp.node.NodeCommitEntries)1 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)1 NodeCommitId (com.enonic.xp.node.NodeCommitId)1 NodeCommitQuery (com.enonic.xp.node.NodeCommitQuery)1 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)1 NodeVersionQuery (com.enonic.xp.node.NodeVersionQuery)1 NodeVersionQueryResult (com.enonic.xp.node.NodeVersionQueryResult)1