Example usage for org.apache.commons.lang3.tuple ImmutablePair getRight

List of usage examples for org.apache.commons.lang3.tuple ImmutablePair getRight

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple ImmutablePair getRight.

Prototype

@Override
public R getRight() 

Source Link

Usage

From source file:io.lavagna.model.EventFull.java

public EventFull(Event event, User user, ImmutablePair<Board, Card> bc, String content,
        ImmutablePair<Board, Card> labelCard, User labelUser) {
    this.event = event;
    this.userProvider = user.getProvider();
    this.username = user.getUsername();
    this.boardShortName = bc.getLeft().getShortName();
    this.cardSequenceNumber = bc.getRight().getSequence();
    this.content = content;
    ///*from  w  w w  . j ava  2 s  . c  o m*/

    if (labelCard != null) {
        this.labelBoardShortName = labelCard.getLeft().getShortName();
        this.labelCardSequenceNumber = labelCard.getRight().getSequence();
    } else {
        this.labelBoardShortName = null;
        this.labelCardSequenceNumber = null;
    }

    if (labelUser != null) {
        this.labelUserProvider = labelUser.getProvider();
        this.labelUsername = labelUser.getUsername();
    } else {
        this.labelUserProvider = null;
        this.labelUsername = null;
    }
}

From source file:io.lavagna.web.api.BulkOperationLabelController.java

@ExpectPermission(Permission.UPDATE_CARD)
@RequestMapping(value = "/api/project/{projectShortName}/bulk-op/set-due-date", method = RequestMethod.POST)
public void setDueDate(@PathVariable("projectShortName") String projectShortName, @RequestBody BulkOperation op,
        User user) {/*  w  w w .jav a  2s. c  om*/
    ImmutablePair<List<Integer>, List<Integer>> updatedAndAdded = bulkOperationService
            .setDueDate(projectShortName, op.cardIds, op.value, user);
    eventEmitter.emitUpdateOrAddValueToCards(cardRepository.findAllByIds(updatedAndAdded.getLeft()),
            cardRepository.findAllByIds(updatedAndAdded.getRight()));
}

From source file:io.lavagna.web.api.BulkOperationLabelController.java

@ExpectPermission(Permission.UPDATE_CARD)
@RequestMapping(value = "/api/project/{projectShortName}/bulk-op/set-milestone", method = RequestMethod.POST)
public void setMilestone(@PathVariable("projectShortName") String projectShortName,
        @RequestBody BulkOperation op, User user) {
    ImmutablePair<List<Integer>, List<Integer>> updatedAndAdded = bulkOperationService
            .setMilestone(projectShortName, op.cardIds, op.value, user);
    eventEmitter.emitUpdateOrAddValueToCards(cardRepository.findAllByIds(updatedAndAdded.getLeft()),
            cardRepository.findAllByIds(updatedAndAdded.getRight()));
}

From source file:io.cloudslang.content.amazon.actions.network.DescribeNetworkInterfacesAction.java

/**
 * Describes one or more of your network interfaces.
 *
 * @param endpoint                              Optional - Endpoint to which request will be sent.
 *                                              Default: "https://ec2.amazonaws.com"
 * @param identity                              ID of the secret access key associated with your Amazon AWS or
 *                                              IAM account.
 *                                              Example: "AKIAIOSFODNN7EXAMPLE"
 * @param credential                            Secret access key associated with your Amazon AWS or IAM account.
 *                                              Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
 * @param proxyHost                             Optional - proxy server used to connect to Amazon API. If empty no
 *                                              proxy will be used.
 * @param proxyPort                             Optional - proxy server port. You must either specify values for both
 *                                              proxyHost and proxyPort inputs or leave them both empty.
 * @param proxyUsername                         Optional - proxy server user name.
 *                                              Default: ""
 * @param proxyPassword                         Optional - proxy server password associated with the proxyUsername
 *                                              input value.
 * @param version                               Optional - Version of the web service to made the call against it.
 *                                              Example: "2016-11-15"
 *                                              Default: "2016-11-15"
 * @param headers                               Optional - string containing the headers to use for the request
 *                                              separated by new line (CRLF). The header name-value pair will be
 *                                              separated by ":"
 *                                              Format: Conforming with HTTP standard for headers (RFC 2616)
 *                                              Examples: "Accept:text/plain"
 *                                              Default: ""
 * @param queryParams                           Optional - string containing query parameters that will be appended
 *                                              to the URL. The names and the values must not be URL encoded because
 *                                              if they are encoded then a double encoded will occur. The separator
 *                                              between name-value pairs is "&" symbol. The query name will be
 *                                              separated from query value by "="
 *                                              Examples: "parameterName1=parameterValue1&parameterName2=parameterValue2"
 *                                              Default: ""
 * @param delimiter                             Optional - Delimiter that will be used.
 * @param filterAddressesPrivateIpAddress       Optional - The private IPv4 addresses associated with the network
 *                                              interface.
 * @param filterAddressesPrimary                Optional - Whether the private IPv4 address is the primary IP address
 *                                              associated with the network interface.
 * @param filterAddressesAssociationPublicIp    Optional - The association ID returned when the network interface was
 *                                              associated with the Elastic IP address (IPv4).
 * @param filterAddressesAssociationOwnerId     Optional - The owner ID of the addresses associated with the network
 *                                              interface.
 * @param filterAssociationAssociationId        Optional - The association ID returned when the network interface
 *                                              was associated with an IPv4 address.
 * @param filterAssociationAllocationId         Optional - The allocation ID returned when you allocated the Elastic
 *                                              IP address (IPv4) for your network interface.
 * @param filterAssociationIpOwnerId            Optional - The owner of the Elastic IP address (IPv4) associated
 *                                              with the network interface.
 * @param filterAssociationPublicIp             Optional - The address of the Elastic IP address (IPv4) bound to the
 *                                              network interface.
 * @param filterAssociationPublicDnsName        Optional - The public DNS name for the network interface (IPv4).
 * @param filterAttachmentAttachmentId          Optional - The ID of the interface attachment.
 * @param filterAttachmentAttachTime            Optional - The time that the network interface was attached to an
 *                                              instance.
 * @param filterAttachmentDeleteOnTermination   Optional - Indicates whether the attachment is deleted when an
 *                                              instance is terminated.
 * @param filterAttachmentDeviceIndex           Optional - The device index to which the network interface is attached.
 * @param filterAttachmentInstanceId            Optional - The ID of the instance to which the network interface is
 *                                              attached.
 * @param filterAttachmentInstanceOwnerId       Optional - The owner ID of the instance to which the network
 *                                              interface is attached.
 * @param filterAttachmentNatGatewayId          Optional - The ID of the NAT gateway to which the network interface
 *                                              is attached.
 * @param filterAttachmentStatus                Optional - The status of the attachment.
 *                                              Valid values: attaching, attached, detaching, detached.
 * @param filterAvailabilityZone                Optional - The Availability Zone of the network interface.
 * @param filterDescription                     Optional - The description of the network interface.
 * @param filterGroupId                         Optional - The ID of a security group associated with the network
 *                                              interface.
 * @param filterGroupName                       Optional - The name of a security group associated with the network
 *                                              interface.
 * @param filterIpv6AddressesIpv6Address        Optional - An IPv6 address associated with the network interface.
 * @param filterMacAddress                      Optional - The MAC address of the network interface.
 * @param filterNetworkInterfaceId              Optional - The ID of the network interface.
 * @param filterOwnerId                         Optional - The AWS account ID of the network interface owner.
 * @param filterPrivateIpAddress                Optional - The private IPv4 address or addresses of the network
 *                                              interface.
 * @param filterPrivateDnsName                  Optional - The private DNS name of the network interface (IPv4).
 * @param filterRequesterId                     Optional - The ID of the entity that launched the instance on your
 *                                              behalf (for example, AWS Management Console, Auto Scaling, and so on).
 * @param filterRequesterManaged                Optional - Indicates whether the network interface is being managed
 *                                              by an AWS service (for example, AWS Management Console, Auto Scaling,
 *                                              and so on).
 * @param filterSourceDestCheck                 Optional - Indicates whether the network interface performs
 *                                              source/destination checking. A value of true means checking is
 *                                              enabled, and false means checking is disabled. The value must be
 *                                              false for the network interface to perform network address
 *                                              translation (NAT) in your VPC.
 * @param filterStatus                          Optional - The status of the network interface. If the network
 *                                              interface is not attached to an instance, the status is available;
 *                                              if a network interface is attached to an instance the status is in-use.
 *                                              Valid values: in-use, available.
 * @param filterSubnetId                        Optional - The ID of the subnet for the network interface.
 * @param filterTag                             Optional - The key/value combination of a tag assigned to the resource.
 *                                              Specify the key of the tag in the filter name and the value of the
 *                                              tag in the filter value.
 *                                              Example: Purpose1=X,Purpose2=B
 * @param filterTagKey                          Optional - The key of a tag assigned to the resource. This filter is
 *                                              independent of the filterTagValue filter. For example, if you use both
 *                                              filterTagKey = "Purpose" and filterTagValue = "X", you get any
 *                                              resources assigned both the tag key Purpose (regardless of what
 *                                              the tag's value is), and the tag value X (regardless of what the
 *                                              tag's key is). If you want to list only resources where Purpose is X,
 *                                              see the filterTag.
 * @param filterTagValue                        Optional - The value of a tag assigned to the resource. This filter
 *                                              is independent of the filterTagKey.
 * @param filterVpcId                           Optional - The ID of the VPC for the network interface.
 * @param networkInterfaceId                    Optional - String that contains one or more network interface IDs.
 *                                              Example: "eni-12345678,eni-87654321"
 *                                              Default: ""
 * @return A map with strings as keys and strings as values that contains: outcome of the action (or failure message
 *         and the exception if there is one), returnCode of the operation and the ID of the request
 *//*from www .j  a va 2 s . co  m*/
@Action(name = "Describe Network Interfaces", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT),
        @Output(EXCEPTION) }, responses = {
                @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED),
                @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) })
public Map<String, String> execute(@Param(value = ENDPOINT) String endpoint,
        @Param(value = IDENTITY, required = true) String identity,
        @Param(value = CREDENTIAL, required = true, encrypted = true) String credential,
        @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort,
        @Param(value = PROXY_USERNAME) String proxyUsername,
        @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword,
        @Param(value = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams,
        @Param(value = VERSION) String version, @Param(value = DELIMITER) String delimiter,
        @Param(value = FILTER_ADDRESSES_PRIVATE_IP_ADDRESS) String filterAddressesPrivateIpAddress,
        @Param(value = FILTER_ADDRESSES_PRIMARY) String filterAddressesPrimary,
        @Param(value = FILTER_ADDRESSES_ASSOCIATION_PUBLIC_IP) String filterAddressesAssociationPublicIp,
        @Param(value = FILTER_ADDRESSES_ASSOCIATION_OWNER_ID) String filterAddressesAssociationOwnerId,
        @Param(value = FILTER_ASSOCIATION_ASSOCIATION_ID) String filterAssociationAssociationId,
        @Param(value = FILTER_ASSOCIATION_ALLOCATION_ID) String filterAssociationAllocationId,
        @Param(value = FILTER_ASSOCIATION_IP_OWNER_ID) String filterAssociationIpOwnerId,
        @Param(value = FILTER_ASSOCIATION_PUBLIC_IP) String filterAssociationPublicIp,
        @Param(value = FILTER_ASSOCIATION_PUBLIC_DNS_NAME) String filterAssociationPublicDnsName,
        @Param(value = FILTER_ATTACHMENT_ATTACHMENT_ID) String filterAttachmentAttachmentId,
        @Param(value = FILTER_ATTACHMENT_ATTACH_TIME) String filterAttachmentAttachTime,
        @Param(value = FILTER_ATTACHMENT_DELETE_ON_TERMINATION) String filterAttachmentDeleteOnTermination,
        @Param(value = FILTER_ATTACHMENT_DEVICE_INDEX) String filterAttachmentDeviceIndex,
        @Param(value = FILTER_ATTACHMENT_INSTANCE_ID) String filterAttachmentInstanceId,
        @Param(value = FILTER_ATTACHMENT_INSTANCE_OWNER_ID) String filterAttachmentInstanceOwnerId,
        @Param(value = FILTER_ATTACHMENT_NAT_GATEWAY_ID) String filterAttachmentNatGatewayId,
        @Param(value = FILTER_ATTACHMENT_STATUS) String filterAttachmentStatus,
        @Param(value = FILTER_AVAILABILITY_ZONE) String filterAvailabilityZone,
        @Param(value = FILTER_DESCRIPTION) String filterDescription,
        @Param(value = FILTER_GROUP_ID) String filterGroupId,
        @Param(value = FILTER_GROUP_NAME) String filterGroupName,
        @Param(value = FILTER_IPV6_ADDRESSES_IPV6_ADDRESS) String filterIpv6AddressesIpv6Address,
        @Param(value = FILTER_MAC_ADDRESS) String filterMacAddress,
        @Param(value = FILTER_NETWORK_INTERFACE_ID) String filterNetworkInterfaceId,
        @Param(value = FILTER_OWNER_ID) String filterOwnerId,
        @Param(value = FILTER_PRIVATE_IP_ADDRESS) String filterPrivateIpAddress,
        @Param(value = FILTER_PRIVATE_DNS_NAME) String filterPrivateDnsName,
        @Param(value = FILTER_REQUESTER_ID) String filterRequesterId,
        @Param(value = FILTER_REQUESTER_MANAGED) String filterRequesterManaged,
        @Param(value = FILTER_SOURCE_DEST_CHECK) String filterSourceDestCheck,
        @Param(value = FILTER_STATUS) String filterStatus,
        @Param(value = FILTER_SUBNET_ID) String filterSubnetId, @Param(value = FILTER_TAG) String filterTag,
        @Param(value = FILTER_TAG_KEY) String filterTagKey,
        @Param(value = FILTER_TAG_VALUE) String filterTagValue,
        @Param(value = FILTER_VPC_ID) String filterVpcId,
        @Param(value = NETWORK_INTERFACE_ID) String networkInterfaceId) {
    try {
        version = getDefaultStringInput(version, NETWORK_DEFAULT_API_VERSION);

        final CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, EC2_API, EMPTY)
                .withIdentity(identity).withCredential(credential).withProxyHost(proxyHost)
                .withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword)
                .withHeaders(headers).withQueryParams(queryParams).withVersion(version).withDelimiter(delimiter)
                .withAction(DESCRIBE_NETWORK_INTERFACES).withApiService(EC2_API).withRequestUri(EMPTY)
                .withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();

        final NetworkInputs networkInputs = new NetworkInputs.Builder()
                .withNetworkInterfaceId(networkInterfaceId).build();

        final List<ImmutablePair<String, String>> filterPairs = Arrays.asList(
                of(NetworkFilter.ADDRESSES_ASSOCIATION_OWNER_ID, filterAttachmentAttachTime),
                of(NetworkFilter.ADDRESSES_PRIVATE_IP_ADDRESS, filterAddressesPrivateIpAddress),
                of(NetworkFilter.ADDRESSES_PRIMARY, filterAddressesPrimary),
                of(NetworkFilter.ADDRESSES_ASSOCIATION_PUBLIC_IP, filterAddressesAssociationPublicIp),
                of(NetworkFilter.ADDRESSES_ASSOCIATION_OWNER_ID, filterAddressesAssociationOwnerId),
                of(NetworkFilter.ASSOCIATION_ASSOCIATION_ID, filterAssociationAssociationId),
                of(NetworkFilter.ASSOCIATION_ALLOCATION_ID, filterAssociationAllocationId),
                of(NetworkFilter.ASSOCIATION_IP_OWNER_ID, filterAssociationIpOwnerId),
                of(NetworkFilter.ASSOCIATION_PUBLIC_IP, filterAssociationPublicIp),
                of(NetworkFilter.ASSOCIATION_PUBLIC_DNS_NAME, filterAssociationPublicDnsName),
                of(NetworkFilter.ATTACHMENT_ATTACHMENT_ID, filterAttachmentAttachmentId),
                of(NetworkFilter.ATTACHMENT_ATTACH_TIME, filterAttachmentAttachTime),
                of(NetworkFilter.ATTACHMENT_DELETE_ON_TERMINATION, filterAttachmentDeleteOnTermination),
                of(NetworkFilter.ATTACHMENT_DEVICE_INDEX, filterAttachmentDeviceIndex),
                of(NetworkFilter.ATTACHMENT_INSTANCE_ID, filterAttachmentInstanceId),
                of(NetworkFilter.ATTACHMENT_INSTANCE_OWNER_ID, filterAttachmentInstanceOwnerId),
                of(NetworkFilter.ATTACHMENT_NAT_GATEWAY_ID, filterAttachmentNatGatewayId),
                of(NetworkFilter.ATTACHMENT_STATUS, filterAttachmentStatus),
                of(NetworkFilter.AVAILABILITY_ZONE, filterAvailabilityZone),
                of(NetworkFilter.DESCRIPTION, filterDescription), of(NetworkFilter.GROUP_ID, filterGroupId),
                of(NetworkFilter.GROUP_NAME, filterGroupName),
                of(NetworkFilter.IPV6_ADDRESSES_IPV6_ADDRESS, filterIpv6AddressesIpv6Address),
                of(NetworkFilter.MAC_ADDRESS, filterMacAddress),
                of(NetworkFilter.NETWORK_INTERFACE_ID, filterNetworkInterfaceId),
                of(NetworkFilter.OWNER_ID, filterOwnerId),
                of(NetworkFilter.PRIVATE_IP_ADDRESS, filterPrivateIpAddress),
                of(NetworkFilter.PRIVATE_DNS_NAME, filterPrivateDnsName),
                of(NetworkFilter.REQUESTER_ID, filterRequesterId),
                of(NetworkFilter.REQUESTER_MANAGED, filterRequesterManaged),
                of(NetworkFilter.SOURCE_DEST_CHECK, filterSourceDestCheck),
                of(NetworkFilter.STATUS, filterStatus), of(NetworkFilter.SUBNET_ID, filterSubnetId),
                of(NetworkFilter.TAG_KEY, filterTagKey), of(NetworkFilter.TAG_VALUE, filterTagValue),
                of(NetworkFilter.VPC_ID, filterVpcId));

        final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder()
                .withDelimiter(commonInputs.getDelimiter());

        for (ImmutablePair<String, String> filterPair : filterPairs) {
            if (isNotEmpty(filterPair.getRight())) {
                filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight());
            }
        }

        if (isNotEmpty(filterTag)) {
            processTagFilter(filterTag, commonInputs.getDelimiter(), filterInputsBuilder);
        }

        final FilterInputs filterInputs = filterInputsBuilder.build();

        return new QueryApiExecutor().execute(commonInputs, networkInputs, filterInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}

From source file:forge.deck.generation.DeckGeneratorBase.java

protected void addCmcAdjusted(Iterable<PaperCard> source, int cnt,
        List<ImmutablePair<FilterCMC, Integer>> cmcLevels) {
    int totalWeight = 0;
    for (ImmutablePair<FilterCMC, Integer> pair : cmcLevels) {
        totalWeight += pair.getRight();
    }/*www.  jav a2s .  c  om*/

    float variability = 0.6f; // if set to 1, you'll get minimum cards to choose from
    float desiredWeight = (float) cnt / (maxDuplicates * variability);
    float desiredOverTotal = desiredWeight / totalWeight;
    float requestedOverTotal = (float) cnt / totalWeight;

    for (ImmutablePair<FilterCMC, Integer> pair : cmcLevels) {
        Iterable<PaperCard> matchingCards = Iterables.filter(source,
                Predicates.compose(pair.getLeft(), PaperCard.FN_GET_RULES));
        int cmcCountForPool = (int) Math.ceil(pair.getRight().intValue() * desiredOverTotal);

        int addOfThisCmc = Math.round(pair.getRight().intValue() * requestedOverTotal);
        tmpDeck.append(String.format("Adding %d cards for cmc range from a pool with %d cards:%n", addOfThisCmc,
                cmcCountForPool));

        final List<PaperCard> curved = Aggregates.random(matchingCards, cmcCountForPool);
        final List<PaperCard> curvedRandomized = Lists.newArrayList();
        for (PaperCard c : curved) {
            cardCounts.put(c.getName(), 0);
            curvedRandomized.add(pool.getCard(c.getName()));
        }

        addSome(addOfThisCmc, curvedRandomized);
    }
}

From source file:io.cloudslang.content.vmware.services.DeployOvfTemplateServiceTest.java

private void verifyMockInvocationsForCreateLeaseSetupTest(
        ImmutablePair<ManagedObjectReference, OvfCreateImportSpecResult> result, boolean withClustername)
        throws Exception {
    Assert.assertEquals(httpNfcLeaseMock, result.getLeft());
    Assert.assertEquals(ovfCreateImportSpecResultMock, result.getRight());
    verifyNew(VmUtils.class).withNoArguments();
    if (withClustername) {
        verify(vmInputsMock, times(2)).getClusterName();
        verify(vmUtilsMock, times(0)).getMorResourcePool(TEST_RESOURCE_POOL, connectionResourcesMock);
        verifyNew(MorObjectHandler.class).withNoArguments();
        verify(morObjectHandlerMock).getSpecificMor(connectionResourcesMock, morRootFolderMock,
                "ClusterComputeResource", TEST_CLUSTER);
        verify(vmUtilsMock).getMorResourcePoolFromCluster(connectionResourcesMock, clusterMorMock,
                TEST_RESOURCE_POOL);/*from  w  ww  .ja v  a  2  s  .  co  m*/
    } else {
        verify(vmInputsMock).getClusterName();
        verify(vmUtilsMock).getMorResourcePool(TEST_RESOURCE_POOL, connectionResourcesMock);
        verify(vmUtilsMock, times(0)).getMorResourcePoolFromCluster(connectionResourcesMock, clusterMorMock,
                TEST_RESOURCE_POOL);
    }
    verify(vmUtilsMock).getMorHost(anyString(), any(ConnectionResources.class),
            any(ManagedObjectReference.class));
    verify(vmUtilsMock).getMorDataStore(anyString(), any(ConnectionResources.class),
            any(ManagedObjectReference.class), any(VmInputs.class));
    verify(vmUtilsMock).getMorFolder(anyString(), any(ConnectionResources.class));
    verify(connectionResourcesMock).getVimPortType();
    verify(vimPortTypeMock).createImportSpec(ovfManagerMock, OVF_TEMPLATE_AS_STRING, resourcePoolMock,
            datastoreMock, ovfCreateImportSpecParamsMock);
}

From source file:com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByOperatorService.java

/**
 * Given a group by result, return a group by result trimmed to provided size.
 * Sorting ordering is determined based on aggregation function.
 *
 * @param aggregationFunction/* w  ww  . ja v  a2 s  .com*/
 * @param aggregationGroupByResult
 * @param trimSize
 * @return
 */
private Map<String, Serializable> trimToSize(AggregationFunction aggregationFunction,
        Map<String, Serializable> aggregationGroupByResult, int trimSize) {

    boolean reverseOrder = aggregationFunction.getFunctionName().startsWith(MIN_PREFIX);
    MinMaxPriorityQueue<ImmutablePair<Serializable, String>> minMaxPriorityQueue = getMinMaxPriorityQueue(
            aggregationGroupByResult.values().iterator().next(), trimSize, reverseOrder);

    if (minMaxPriorityQueue == null) {
        return aggregationGroupByResult;
    }

    // The MinMaxPriorityQueue will add only the TOP N elements.
    for (String groupedKey : aggregationGroupByResult.keySet()) {
        minMaxPriorityQueue.add(new ImmutablePair(aggregationGroupByResult.get(groupedKey), groupedKey));
    }

    Map<String, Serializable> trimmedResult = new HashMap<>();
    ImmutablePair<Serializable, String> pair;
    while ((pair = (ImmutablePair) minMaxPriorityQueue.pollFirst()) != null) {
        trimmedResult.put(pair.getRight(), pair.getLeft());
    }
    return trimmedResult;
}

From source file:edu.umich.flowfence.service.KVSSharedPrefs.java

@Override
@SuppressWarnings("unchecked")
public synchronized Map<String, ?> getAll() {
    checkRead();//from ww w  . ja  v  a  2  s.c  o  m
    TaintSet.Builder tsb = new TaintSet.Builder();
    Map<String, Object> data = new HashMap<>();

    for (Map.Entry<ImmutablePair<String, String>, ?> entry : mPrefs.getAll().entrySet()) {
        ImmutablePair<String, String> typeAndKey = entry.getKey();
        if (DATA.equals(typeAndKey.getLeft())) {
            // If this is a data entry, remember it.
            data.put(typeAndKey.getRight(), entry.getValue());
        } else if (TAINT.equals(typeAndKey.getKey())) {
            // If this is a taint entry, add it to the overall taint label.
            tsb.unionWith((TaintSet) entry.getValue());
        }
    }

    if (mSandbox != null) {
        mSandbox.addTaint(tsb.build());
    }

    return data;
}

From source file:io.cloudslang.content.vmware.services.DeployOvfTemplateService.java

public void deployOvfTemplate(final HttpInputs httpInputs, final VmInputs vmInputs, final String templatePath,
        final Map<String, String> ovfNetworkMap, final Map<String, String> ovfPropertyMap) throws Exception {
    final ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
    try {//from  w w w.  jav a  2 s . co m
        final ImmutablePair<ManagedObjectReference, OvfCreateImportSpecResult> pair = createLeaseSetup(
                connectionResources, vmInputs, templatePath, ovfNetworkMap, ovfPropertyMap);
        final ManagedObjectReference httpNfcLease = pair.getLeft();
        final OvfCreateImportSpecResult importSpecResult = pair.getRight();

        final HttpNfcLeaseInfo httpNfcLeaseInfo = getHttpNfcLeaseInfoWhenReady(connectionResources,
                httpNfcLease);
        final List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
        final ProgressUpdater progressUpdater = executor.isParallel()
                ? new AsyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease,
                        connectionResources)
                : new SyncProgressUpdater(getDisksTotalNoBytes(importSpecResult), httpNfcLease,
                        connectionResources);

        executor.execute(progressUpdater);
        transferVmdkFiles(templatePath, importSpecResult, deviceUrls, progressUpdater);
        executor.shutdown();
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }
}

From source file:io.lavagna.service.MailTicketService.java

public void checkNew() {
    List<ProjectMailTicketConfig> entries = mailTicketRepository.findAll();

    for (ProjectMailTicketConfig entry : entries) {
        if (entry.getEntries().size() == 0 || !entry.getEnabled()) {
            continue;
        }/*from www .  j  av  a 2 s.  c  om*/

        MailReceiver receiver = entry.getConfig().getInboundProtocol().startsWith("pop3")
                ? getPop3MailReceiver(entry.getConfig())
                : getImapMailReceiver(entry.getConfig());

        try {
            Date updateLastChecked = entry.getLastChecked();

            Object[] messages = receiver.receive();
            LOG.debug("found {} messages", messages.length);

            for (int i = 0; i < messages.length; i++) {
                MimeMessage message = (MimeMessage) messages[i];
                if (!message.getReceivedDate().after(entry.getLastChecked())) {
                    continue;
                } else {
                    updateLastChecked = message.getReceivedDate().after(updateLastChecked)
                            ? message.getReceivedDate()
                            : updateLastChecked;
                }

                String deliveredTo = getDeliveredTo(message);

                for (ProjectMailTicket ticketConfig : entry.getEntries()) {
                    if (ticketConfig.getEnabled() && ticketConfig.getAlias().equals(deliveredTo)) {
                        String from = getFrom(message);
                        String name = getName(message);
                        Matcher m = CARD_SHORT_NAME.matcher(message.getSubject());

                        if (!m.find() || (m.find() && !cardService.existCardWith(m.group("shortname"),
                                Integer.parseInt(m.group("sequence"))))) {
                            try {
                                ImmutablePair<Card, User> cardAndUser = createCard(message.getSubject(),
                                        getTextFromMessage(message), from, ticketConfig.getColumnId());

                                notify(cardAndUser.getLeft(), entry, ticketConfig, cardAndUser.getRight(), from,
                                        name);
                            } catch (IOException | MessagingException e) {
                                LOG.error("failed to parse message body", e);
                            }
                        }
                    }
                }
            }

            mailTicketRepository.updateLastChecked(entry.getId(), updateLastChecked);
        } catch (MessagingException e) {
            LOG.error("could not retrieve messages for ticket mail config id: {}", entry.getId());
        }
    }
}