Search in sources :

Example 1 with ResolveSyncWorkResult

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

the class DiffBranchesHandler method execute.

@Override
public Object execute() {
    final NodeId nodeId = getNodeId(this.nodeKey);
    if (nodeId == null) {
        throw new NodeNotFoundException("Node with key [" + this.nodeKey + "] not found");
    }
    final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).nodeId(nodeId).branch(targetBranch).build());
    return new ResolveSyncWorkResultMapper(result);
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) ResolveSyncWorkResultMapper(com.enonic.xp.lib.node.mapper.ResolveSyncWorkResultMapper) NodeId(com.enonic.xp.node.NodeId) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult)

Example 2 with ResolveSyncWorkResult

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

the class ResolveSyncWorkPerformanceTest method testReferencePerformance.

@Disabled
@Test
public void testReferencePerformance() throws Exception {
    final Node rootNode = createNode(CreateNodeParams.create().name("rootNode").parent(NodePath.ROOT).build(), false);
    createNodes(rootNode, 40, 3, 1);
    refresh();
    final Stopwatch started = Stopwatch.createStarted();
    final ResolveSyncWorkResult resolvedNodes = ResolveSyncWorkCommand.create().nodeId(rootNode.id()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    started.stop();
    System.out.println(resolvedNodes.getSize() + " in " + started);
}
Also used : Node(com.enonic.xp.node.Node) Stopwatch(com.google.common.base.Stopwatch) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with ResolveSyncWorkResult

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

the class PushNodesCommandPerformanceTest method testReferencePerformance.

@Disabled
@Test
public void testReferencePerformance() throws Exception {
    final Node rootNode = createNode(CreateNodeParams.create().name("rootNode").parent(NodePath.ROOT).build(), false);
    createNodes(rootNode, 20, 3, 1);
    refresh();
    final ResolveSyncWorkResult syncWork = ResolveSyncWorkCommand.create().nodeId(rootNode.id()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    final Stopwatch started = Stopwatch.createStarted();
    final PushNodesResult result = PushNodesCommand.create().ids(syncWork.getNodeComparisons().getNodeIds()).target(WS_OTHER).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
    started.stop();
    final long elapsed = started.elapsed(TimeUnit.SECONDS);
    final int number = result.getSuccessful().getSize();
    System.out.println("Pushed : " + number + " in " + started + ", " + (elapsed == 0 ? "n/a" : (number / elapsed) + "/s"));
}
Also used : Node(com.enonic.xp.node.Node) Stopwatch(com.google.common.base.Stopwatch) PushNodesResult(com.enonic.xp.node.PushNodesResult) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 4 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method do_not_publish_other_children_of_dependent_parent.

/*
     - S1 (New)
         - A1 (New)
         - A2 (New)
             - A2_1 - Ref:B2_1 (New)
               - A2_1_1
     - S2 (New)
         - B1 (New)
         - B2 (New)
             - B2_1 (New)
             - B2_2 (New)

      Resolve: A2_1
    */
@Test
public void do_not_publish_other_children_of_dependent_parent() throws Exception {
    createS1S2Tree();
    // Add child-node to B2
    createNode(CreateNodeParams.create().setNodeId(NodeId.from("b2_2")).parent(NodePath.create("/s2/b2").build()).name("b2_2").build());
    final ResolveSyncWorkResult result = resolveSyncWorkResult("a2_1");
    assertEquals(6, result.getSize());
    assertNodes(result, ExpectedNodes.create().implicit("a2_1").parent("a2", "s1").referred("b2_1").parent("b2", "s2"));
}
Also used : ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Example 5 with ResolveSyncWorkResult

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

the class ResolveSyncWorkCommandTest method include_referred_nodes.

@Test
public void include_referred_nodes() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).name("node1").build());
    final PropertyTree node1_1_data = new PropertyTree();
    node1_1_data.addReference("myRef", Reference.from("node2"));
    final Node node1_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node1_1")).parent(node1.path()).name("node1_1").data(node1_1_data).build());
    final Node node2 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2")).parent(NodePath.ROOT).name("node2").build());
    final Node node2_1 = createNode(CreateNodeParams.create().setNodeId(NodeId.from("node2_1")).parent(node2.path()).name("node2_1").build());
    final ResolveSyncWorkResult result = resolveSyncWorkResult(node1_1.id(), false);
    assertNodes(result, ExpectedNodes.create().implicit(node1_1.id()).parent(node1.id()).referred(node2.id()));
}
Also used : Node(com.enonic.xp.node.Node) PropertyTree(com.enonic.xp.data.PropertyTree) ResolveSyncWorkResult(com.enonic.xp.node.ResolveSyncWorkResult) Test(org.junit.jupiter.api.Test)

Aggregations

ResolveSyncWorkResult (com.enonic.xp.node.ResolveSyncWorkResult)44 Test (org.junit.jupiter.api.Test)39 Node (com.enonic.xp.node.Node)14 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodeId (com.enonic.xp.node.NodeId)3 ContentId (com.enonic.xp.content.ContentId)2 NodeIds (com.enonic.xp.node.NodeIds)2 Stopwatch (com.google.common.base.Stopwatch)2 Disabled (org.junit.jupiter.api.Disabled)2 Branch (com.enonic.xp.branch.Branch)1 CompareContentResults (com.enonic.xp.content.CompareContentResults)1 CompareStatus (com.enonic.xp.content.CompareStatus)1 ContentIds (com.enonic.xp.content.ContentIds)1 ResolveSyncWorkResultMapper (com.enonic.xp.lib.node.mapper.ResolveSyncWorkResultMapper)1 NodeComparison (com.enonic.xp.node.NodeComparison)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 PushNodesResult (com.enonic.xp.node.PushNodesResult)1 SyncWorkResolverParams (com.enonic.xp.node.SyncWorkResolverParams)1 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)1 Preconditions (com.google.common.base.Preconditions)1