Search in sources :

Example 71 with Arrays.asList

use of java.util.Arrays.asList in project alfresco-repository by Alfresco.

the class EventsServiceImpl method nodeMoved.

@Override
public void nodeMoved(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) {
    NodeRef nodeRef = newChildAssocRef.getChildRef();
    NodeInfo nodeInfo = getNodeInfo(nodeRef, NodeMovedEvent.EVENT_TYPE);
    if (nodeInfo.checkNodeInfo()) {
        String username = AuthenticationUtil.getFullyAuthenticatedUser();
        String networkId = TenantUtil.getCurrentDomain();
        String objectId = nodeInfo.getNodeId();
        String siteId = nodeInfo.getSiteId();
        String txnId = AlfrescoTransactionSupport.getTransactionId();
        long timestamp = System.currentTimeMillis();
        Long modificationTime = nodeInfo.getModificationTimestamp();
        String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
        NodeRef oldParentNodeRef = oldChildAssocRef.getParentRef();
        NodeRef newParentNodeRef = newChildAssocRef.getParentRef();
        NodeRef oldNodeRef = oldChildAssocRef.getChildRef();
        NodeRef newNodeRef = newChildAssocRef.getChildRef();
        String oldParentNodeName = (String) nodeService.getProperty(oldParentNodeRef, ContentModel.PROP_NAME);
        String newParentNodeName = (String) nodeService.getProperty(newParentNodeRef, ContentModel.PROP_NAME);
        String oldNodeName = (String) nodeService.getProperty(oldNodeRef, ContentModel.PROP_NAME);
        String newNodeName = (String) nodeService.getProperty(newNodeRef, ContentModel.PROP_NAME);
        List<Path> newParentPaths = nodeService.getPaths(newParentNodeRef, false);
        List<String> newPaths = getPaths(newParentPaths, Arrays.asList(newParentNodeName, newNodeName));
        // renames are handled by an onUpdateProperties callback, we just deal with real moves here.
        if (!oldParentNodeRef.equals(newParentNodeRef)) {
            List<List<String>> toParentNodeIds = getNodeIds(newParentPaths);
            List<Path> oldParentPaths = nodeService.getPaths(oldParentNodeRef, false);
            List<String> previousPaths = getPaths(oldParentPaths, Arrays.asList(oldParentNodeName, oldNodeName));
            List<List<String>> previousParentNodeIds = getNodeIds(oldParentPaths);
            Set<String> aspects = nodeInfo.getAspectsAsStrings();
            Map<String, Serializable> properties = nodeInfo.getProperties();
            Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());
            Event event = new NodeMovedEvent(nextSequenceNumber(), oldNodeName, newNodeName, txnId, timestamp, networkId, siteId, objectId, nodeType, previousPaths, previousParentNodeIds, username, modificationTime, newPaths, toParentNodeIds, alfrescoClient, aspects, properties);
            sendEvent(event);
        }
    }
}
Also used : Path(org.alfresco.service.cmr.repository.Path) Serializable(java.io.Serializable) NodeMovedEvent(org.alfresco.sync.events.types.NodeMovedEvent) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeUnFavouritedEvent(org.alfresco.sync.events.types.NodeUnFavouritedEvent) LocalPermissionRevokedEvent(org.alfresco.sync.events.types.permission.LocalPermissionRevokedEvent) RecordRejectedEvent(org.alfresco.sync.events.types.recordsmanagement.RecordRejectedEvent) NodeUnLikedEvent(org.alfresco.sync.events.types.NodeUnLikedEvent) AuthorityRemovedFromGroupEvent(org.alfresco.sync.events.types.authority.AuthorityRemovedFromGroupEvent) NodeContentGetEvent(org.alfresco.sync.events.types.NodeContentGetEvent) LocalPermissionGrantedEvent(org.alfresco.sync.events.types.permission.LocalPermissionGrantedEvent) NodeUnlockedEvent(org.alfresco.sync.events.types.NodeUnlockedEvent) NodeAddedEvent(org.alfresco.sync.events.types.NodeAddedEvent) InheritPermissionsEnabledEvent(org.alfresco.sync.events.types.permission.InheritPermissionsEnabledEvent) NodeContentPutEvent(org.alfresco.sync.events.types.NodeContentPutEvent) AuthorityAddedToGroupEvent(org.alfresco.sync.events.types.authority.AuthorityAddedToGroupEvent) NodeCheckOutCancelledEvent(org.alfresco.sync.events.types.NodeCheckOutCancelledEvent) InheritPermissionsDisabledEvent(org.alfresco.sync.events.types.permission.InheritPermissionsDisabledEvent) NodeCheckedOutEvent(org.alfresco.sync.events.types.NodeCheckedOutEvent) Event(org.alfresco.sync.events.types.Event) NodeMovedEvent(org.alfresco.sync.events.types.NodeMovedEvent) NodeLikedEvent(org.alfresco.sync.events.types.NodeLikedEvent) RecordCreatedEvent(org.alfresco.sync.events.types.recordsmanagement.RecordCreatedEvent) NodeUpdatedEvent(org.alfresco.sync.events.types.NodeUpdatedEvent) NodeCommentedEvent(org.alfresco.sync.events.types.NodeCommentedEvent) NodeRenamedEvent(org.alfresco.sync.events.types.NodeRenamedEvent) NodeUnTaggedEvent(org.alfresco.sync.events.types.NodeUnTaggedEvent) FileClassifiedEvent(org.alfresco.sync.events.types.recordsmanagement.FileClassifiedEvent) NodeLockedEvent(org.alfresco.sync.events.types.NodeLockedEvent) NodeFavouritedEvent(org.alfresco.sync.events.types.NodeFavouritedEvent) GroupDeletedEvent(org.alfresco.sync.events.types.authority.GroupDeletedEvent) NodeRemovedEvent(org.alfresco.sync.events.types.NodeRemovedEvent) NodeCheckedInEvent(org.alfresco.sync.events.types.NodeCheckedInEvent) FileUnclassifiedEvent(org.alfresco.sync.events.types.recordsmanagement.FileUnclassifiedEvent) NodeTaggedEvent(org.alfresco.sync.events.types.NodeTaggedEvent) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Client(org.alfresco.sync.repo.Client)

Example 72 with Arrays.asList

use of java.util.Arrays.asList in project alfresco-repository by Alfresco.

the class EventsServiceImpl method secondaryAssociationDeleted.

@Override
public void secondaryAssociationDeleted(final ChildAssociationRef secAssociation) {
    NodeInfo nodeInfo = getNodeInfo(secAssociation.getChildRef(), NodeRemovedEvent.EVENT_TYPE);
    if (nodeInfo.checkNodeInfo()) {
        String username = AuthenticationUtil.getFullyAuthenticatedUser();
        String networkId = TenantUtil.getCurrentDomain();
        String name = nodeInfo.getName();
        String objectId = nodeInfo.getNodeId();
        String siteId = nodeInfo.getSiteId();
        String txnId = AlfrescoTransactionSupport.getTransactionId();
        NodeRef secParentNodeRef = secAssociation.getParentRef();
        String secParentNodeName = (String) nodeService.getProperty(secAssociation.getParentRef(), ContentModel.PROP_NAME);
        List<Path> secParentPath = nodeService.getPaths(secParentNodeRef, true);
        List<String> nodePaths = getPaths(secParentPath, Arrays.asList(secParentNodeName, name));
        List<List<String>> pathNodeIds = this.getNodeIds(secParentPath);
        long timestamp = System.currentTimeMillis();
        Long modificationTime = nodeInfo.getModificationTimestamp();
        String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
        Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());
        Set<String> aspects = nodeInfo.getAspectsAsStrings();
        Map<String, Serializable> properties = nodeInfo.getProperties();
        Event event = new NodeRemovedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, alfrescoClient, aspects, properties);
        sendEvent(event);
    }
}
Also used : Path(org.alfresco.service.cmr.repository.Path) Serializable(java.io.Serializable) NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeUnFavouritedEvent(org.alfresco.sync.events.types.NodeUnFavouritedEvent) LocalPermissionRevokedEvent(org.alfresco.sync.events.types.permission.LocalPermissionRevokedEvent) RecordRejectedEvent(org.alfresco.sync.events.types.recordsmanagement.RecordRejectedEvent) NodeUnLikedEvent(org.alfresco.sync.events.types.NodeUnLikedEvent) AuthorityRemovedFromGroupEvent(org.alfresco.sync.events.types.authority.AuthorityRemovedFromGroupEvent) NodeContentGetEvent(org.alfresco.sync.events.types.NodeContentGetEvent) LocalPermissionGrantedEvent(org.alfresco.sync.events.types.permission.LocalPermissionGrantedEvent) NodeUnlockedEvent(org.alfresco.sync.events.types.NodeUnlockedEvent) NodeAddedEvent(org.alfresco.sync.events.types.NodeAddedEvent) InheritPermissionsEnabledEvent(org.alfresco.sync.events.types.permission.InheritPermissionsEnabledEvent) NodeContentPutEvent(org.alfresco.sync.events.types.NodeContentPutEvent) AuthorityAddedToGroupEvent(org.alfresco.sync.events.types.authority.AuthorityAddedToGroupEvent) NodeCheckOutCancelledEvent(org.alfresco.sync.events.types.NodeCheckOutCancelledEvent) InheritPermissionsDisabledEvent(org.alfresco.sync.events.types.permission.InheritPermissionsDisabledEvent) NodeCheckedOutEvent(org.alfresco.sync.events.types.NodeCheckedOutEvent) Event(org.alfresco.sync.events.types.Event) NodeMovedEvent(org.alfresco.sync.events.types.NodeMovedEvent) NodeLikedEvent(org.alfresco.sync.events.types.NodeLikedEvent) RecordCreatedEvent(org.alfresco.sync.events.types.recordsmanagement.RecordCreatedEvent) NodeUpdatedEvent(org.alfresco.sync.events.types.NodeUpdatedEvent) NodeCommentedEvent(org.alfresco.sync.events.types.NodeCommentedEvent) NodeRenamedEvent(org.alfresco.sync.events.types.NodeRenamedEvent) NodeUnTaggedEvent(org.alfresco.sync.events.types.NodeUnTaggedEvent) FileClassifiedEvent(org.alfresco.sync.events.types.recordsmanagement.FileClassifiedEvent) NodeLockedEvent(org.alfresco.sync.events.types.NodeLockedEvent) NodeFavouritedEvent(org.alfresco.sync.events.types.NodeFavouritedEvent) GroupDeletedEvent(org.alfresco.sync.events.types.authority.GroupDeletedEvent) NodeRemovedEvent(org.alfresco.sync.events.types.NodeRemovedEvent) NodeCheckedInEvent(org.alfresco.sync.events.types.NodeCheckedInEvent) FileUnclassifiedEvent(org.alfresco.sync.events.types.recordsmanagement.FileUnclassifiedEvent) NodeTaggedEvent(org.alfresco.sync.events.types.NodeTaggedEvent) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Client(org.alfresco.sync.repo.Client) NodeRemovedEvent(org.alfresco.sync.events.types.NodeRemovedEvent)

Example 73 with Arrays.asList

use of java.util.Arrays.asList in project bullet-core by yahoo.

the class QuantileSketchingStrategyTest method testRounding.

@Test
public void testRounding() {
    QuantileSketchingStrategy distribution = makeDistribution(DistributionType.QUANTILE, 20, 6, 0.0, 1.0, 0.1);
    IntStream.range(0, 10).mapToDouble(i -> i * 0.1).mapToObj(d -> RecordBox.get().add("field", d).getRecord()).forEach(distribution::consume);
    Clip result = distribution.getResult();
    Map<String, Object> metadata = (Map<String, Object>) result.getMeta().asMap().get("meta");
    Assert.assertEquals(metadata.size(), 7);
    Assert.assertFalse((Boolean) metadata.get("isEst"));
    List<BulletRecord> records = result.getRecords();
    Assert.assertEquals(records.size(), 11);
    Set<String> actualQuantilePoints = records.stream().map(r -> r.typedGet(QUANTILE_FIELD).getValue().toString()).collect(Collectors.toSet());
    Set<String> expectedQuantilePoints = new HashSet<>(Arrays.asList("0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0"));
    Assert.assertEquals(actualQuantilePoints, expectedQuantilePoints);
    Assert.assertEquals(distribution.getRecords(), result.getRecords());
    Assert.assertEquals(distribution.getMetadata().asMap(), result.getMeta().asMap());
}
Also used : LinearDistribution(com.yahoo.bullet.query.aggregations.LinearDistribution) IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) ManualDistribution(com.yahoo.bullet.query.aggregations.ManualDistribution) RegionDistribution(com.yahoo.bullet.query.aggregations.RegionDistribution) START_INCLUSIVE(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.START_INCLUSIVE) END_EXCLUSIVE(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.END_EXCLUSIVE) PROBABILITY_FIELD(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.PROBABILITY_FIELD) Concept(com.yahoo.bullet.result.Meta.Concept) Test(org.testng.annotations.Test) RecordBox(com.yahoo.bullet.result.RecordBox) NEGATIVE_INFINITY_START(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.NEGATIVE_INFINITY_START) Clip(com.yahoo.bullet.result.Clip) Family(com.yahoo.sketches.Family) HashSet(java.util.HashSet) Pair(org.apache.commons.lang3.tuple.Pair) Assert(org.testng.Assert) VALUE_FIELD(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.VALUE_FIELD) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Distribution(com.yahoo.bullet.query.aggregations.Distribution) POSITIVE_INFINITY_END(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.POSITIVE_INFINITY_END) BulletRecord(com.yahoo.bullet.record.BulletRecord) DoublesSketch(com.yahoo.sketches.quantiles.DoublesSketch) QUANTILE_FIELD(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.QUANTILE_FIELD) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) TestHelpers.assertApproxEquals(com.yahoo.bullet.TestHelpers.assertApproxEquals) RANGE_FIELD(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.RANGE_FIELD) TestHelpers.addMetadata(com.yahoo.bullet.TestHelpers.addMetadata) BulletConfig(com.yahoo.bullet.common.BulletConfig) DistributionType(com.yahoo.bullet.query.aggregations.DistributionType) COUNT_FIELD(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.COUNT_FIELD) SEPARATOR(com.yahoo.bullet.querying.aggregations.sketches.QuantileSketch.SEPARATOR) Collections(java.util.Collections) Clip(com.yahoo.bullet.result.Clip) BulletRecord(com.yahoo.bullet.record.BulletRecord) Map(java.util.Map) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

Arrays.asList (java.util.Arrays.asList)73 List (java.util.List)66 ArrayList (java.util.ArrayList)49 Test (org.junit.Test)37 Arrays (java.util.Arrays)22 Collections.singletonList (java.util.Collections.singletonList)20 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)18 Test (org.junit.jupiter.api.Test)15 HashMap (java.util.HashMap)14 Before (org.junit.Before)13 Collection (java.util.Collection)12 Stream (java.util.stream.Stream)10 Method (java.lang.reflect.Method)9 Optional (java.util.Optional)9 Collections (java.util.Collections)8 Collections.emptyList (java.util.Collections.emptyList)8 TopicPartition (org.apache.kafka.common.TopicPartition)8 Employee (com.artezio.arttime.datamodel.Employee)6 HourType (com.artezio.arttime.datamodel.HourType)6