List of usage examples for org.apache.commons.lang3.tuple ImmutablePair getLeft
@Override
public L getLeft()
From source file:CWLClientTest.java
/** * This test demonstrates how to extract information from a CWL file. * @throws Exception// ww w . j av a 2 s. c o m */ @Test public void extractCWLTypes() throws Exception { final URL resource = Resources.getResource("cwl.json"); final CWL cwl = new CWL(); final ImmutablePair<String, String> output = cwl.parseCWL(resource.getFile()); final Map<String, String> typeMap = cwl.extractCWLTypes(output.getLeft()); assertTrue(typeMap.size() == 3); assertTrue("int".equals(typeMap.get("mem_gb"))); assertTrue("File".equals(typeMap.get("bam_input"))); }
From source file:eu.bittrade.libs.steemj.configuration.PrivateKeyStorage.java
/** * Get a private key of the given private key type for the given account * name./* w w w . j av a 2s. c o m*/ * * @param privateKeyType * The type of the key to request. * @param accountName * The account to request the key for. * @throws InvalidParameterException * If no key could be find for the given account name. * @return The requested private key. */ public ECKey getKeyForAccount(PrivateKeyType privateKeyType, AccountName accountName) { List<ImmutablePair<PrivateKeyType, ECKey>> privateKeysForAccount = this.getPrivateKeysPerAccounts() .get(accountName); if (privateKeysForAccount == null) { throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName + "' has not been added to the PrivateKeyStore."); } for (ImmutablePair<PrivateKeyType, ECKey> privateKey : privateKeysForAccount) { if (privateKey != null && privateKey.getLeft().equals(privateKeyType)) { return privateKey.getRight(); } } throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName + "' has not been added to the PrivateKeyStore."); }
From source file:io.lavagna.service.importexport.FileUpload.java
@Override void process(EventFull e, Event event, Date time, User user, ImportContext context, Path tempFile) { try {//from w w w. j a v a2 s . co m Path p = Objects.requireNonNull(Read.readFile("files/" + e.getContent(), tempFile)); CardDataUploadContentInfo fileData = Read.readObject("files/" + e.getContent() + ".json", tempFile, new TypeToken<CardDataUploadContentInfo>() { }); ImmutablePair<Boolean, CardData> res = cardDataService.createFile(event.getValueString(), e.getContent(), fileData.getSize(), cardId(e), Files.newInputStream(p), fileData.getContentType(), user, time); if (res.getLeft()) { context.getFileId().put(event.getDataId(), res.getRight().getId()); } Files.delete(p); } catch (IOException ioe) { throw new IllegalStateException("error while handling event FILE_UPLOAD for event: " + e, ioe); } }
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; ///* w w w . j a va2 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:com.telefonica.iot.cygnus.utils.NGSIUtilsTest.java
/** * [NGSIUtils.getGeometry] -------- When getting a geometry, the original attribute is returned when the * attribute type is not geo:point and there is no WGS84 geometry metadata. *///ww w. ja v a2s .co m @Test public void testGetGeometryNoGeolocation() { System.out.println(getTestTraceHead("[Utils.getLocation]") + "-------- When getting a geometry, the original attribute is returned when the attribute " + "type is not geo:point and there is no WGS84 location metadata"); String attrMetadataStr = "[]"; String attrValue = "-3.7167, 40.3833"; String attrType = "coordinates"; boolean swapCoordinates = false; // irrelevant for this test ImmutablePair<String, Boolean> geometry = NGSIUtils.getGeometry(attrValue, attrType, attrMetadataStr, swapCoordinates); try { assertEquals(attrValue, geometry.getLeft()); System.out.println(getTestTraceHead("[Utils.getLocation]") + "- OK - Geometry '" + geometry.getLeft() + "' obtained for a not geolocated attribute"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[Utils.getLocation]") + "- FAIL - Geometry '" + geometry.getLeft() + "' obtained for a not geolocated attribute"); throw e; } // try catch // try catch }
From source file:io.cloudslang.content.amazon.actions.tags.DescribeTagsAction.java
/** * Describes one or more of the tags for your EC2 resources. * * @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¶meterName2=parameterValue2" * Default: "" * @param delimiter Optional - Delimiter that will be used between filter values. * Default: "," * @param filterKey Optional - The tag key. * Default: "" * @param filterResourceId Optional - The resource ID. * Default: "" * @param filterResourceType Optional - The resource type. * Valid values: customer-gateway, dhcp-options, image, instance, * internet-gateway, network-acl, network-interface, reserved-instances, * route-table, security-group, snapshot, spot-instances-request, * subnet, volume, vpc, vpn-connection, vpn-gateway. * Default: "" * @param filterValue Optional - The tag value. * Default: "" * @param maxResults Optional - The maximum number of results to return in a single call. * This value can be between 5 and 1000. To retrieve the remaining * results, make another call with the returned NextToken value. * Default: "" * @param nextToken Optional - The token to retrieve the next page of results. * 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 */// www. ja v a 2s . c om @Action(name = "Describe Tags", 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_KEY) String filterKey, @Param(value = FILTER_RESOURCE_ID) String filterResourceId, @Param(value = FILTER_RESOURCE_TYPE) String filterResourceType, @Param(value = FILTER_VALUE) String filterValue, @Param(value = MAX_RESULTS) String maxResults, @Param(value = NEXT_TOKEN) String nextToken) { try { version = getDefaultStringInput(version, TAGS_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_TAGS).withApiService(EC2_API).withRequestUri(EMPTY) .withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build(); final List<ImmutablePair<String, String>> filterPairs = Arrays.asList(of(KEY, filterKey), of(RESOURCE_ID, filterResourceId), of(RESOURCE_TYPE, filterResourceType), of(VALUE, filterValue)); final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder() .withDelimiter(commonInputs.getDelimiter()).withMaxResults(maxResults).withNextToken(nextToken); for (ImmutablePair<String, String> filterPair : filterPairs) { if (isNotEmpty(filterPair.getRight())) { filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight()); } } final FilterInputs filterInputs = filterInputsBuilder.build(); return new QueryApiExecutor().execute(commonInputs, filterInputs); } catch (Exception exception) { return ExceptionProcessor.getExceptionResult(exception); } }
From source file:com.telefonica.iot.cygnus.utils.NGSIUtilsTest.java
/** * [NGSIUtils.getGeometry] -------- When getting a geometry, a CartoDB point is obtained when passing * an attribute of type 'geo:point'.// w w w . ja va2 s. co m */ @Test public void testGetGeometryGeopoint() { System.out.println(getTestTraceHead("[Utils.getLocation]") + "-------- When getting a geometry, a CartoDB point is obtained when passing an attribute " + "of type 'geo:point'"); String attrMetadataStr = "[]"; String attrValue = "-3.7167, 40.3833"; String attrType = "geo:point"; boolean swapCoordinates = false; // irrelevant for this test ImmutablePair<String, Boolean> geometry = NGSIUtils.getGeometry(attrValue, attrType, attrMetadataStr, swapCoordinates); try { assertEquals("ST_SetSRID(ST_MakePoint(-3.7167,40.3833), 4326)", geometry.getLeft()); System.out.println(getTestTraceHead("[Utils.getLocation]") + "- OK - Geometry '" + geometry.getLeft() + "' obtained for an attribute of type '" + attrType + "' and value '" + attrValue + "'"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[Utils.getLocation]") + "- FAIL - Geometry '" + geometry.getLeft() + "' obtained for an attribute of type '" + attrType + "' and value '" + attrValue + "'"); throw e; } // try catch // try catch }
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) {//from w ww. j ava 2 s .com 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:com.telefonica.iot.cygnus.utils.NGSIUtilsTest.java
/** * [NGSIUtils.getGeometry] -------- When getting a geometry, a CartoDB point is obtained when passing * an attribute with 'geometry' metadata. *//*from w ww . j av a2 s . c om*/ @Test public void testGetGeometryMetadata() { System.out.println(getTestTraceHead("[Utils.getLocation]") + "-------- When getting a geometry, a CartoDB point is obtained when passing an attribute " + "with 'location' metadata"); JSONObject metadataJson = new JSONObject(); metadataJson.put("name", "location"); metadataJson.put("type", "string"); metadataJson.put("value", "WGS84"); JSONArray metadatasJson = new JSONArray(); metadatasJson.add(metadataJson); String attrMetadataStr = metadatasJson.toJSONString(); String attrValue = "-3.7167, 40.3833"; String attrType = "coordinates"; // irrelevant for this test boolean swapCoordinates = false; // irrelevant for this test ImmutablePair<String, Boolean> geometry = NGSIUtils.getGeometry(attrValue, attrType, attrMetadataStr, swapCoordinates); try { assertEquals("ST_SetSRID(ST_MakePoint(-3.7167,40.3833), 4326)", geometry.getLeft()); System.out.println(getTestTraceHead("[Utils.getLocation]") + "- OK - Geometry '" + geometry.getLeft() + "' obtained for an attribute with metadata '" + attrMetadataStr + "' and value '" + attrValue + "'"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[Utils.getLocation]") + "- FAIL - Geometry '" + geometry.getLeft() + "' obtained for an attribute with metadata '" + attrMetadataStr + "' and value '" + attrValue + "'"); throw e; } // try catch // try catch }