Example usage for java.util List replaceAll

List of usage examples for java.util List replaceAll

Introduction

In this page you can find the example usage for java.util List replaceAll.

Prototype

default void replaceAll(UnaryOperator<E> operator) 

Source Link

Document

Replaces each element of this list with the result of applying the operator to that element.

Usage

From source file:com.epam.dlab.backendapi.dao.aws.AwsBillingDAO.java

private void usersToLowerCase(List<String> users) {
    if (users != null) {
        users.replaceAll(String::toLowerCase);
    }/* w w w.  ja  v  a2s .  co m*/
}

From source file:de.steilerdev.myVerein.server.controller.user.DivisionController.java

@RequestMapping(value = "sync", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<List<Division>> syncUserDivision(@CurrentUser User currentUser) {
    logger.trace("[" + currentUser + "] Syncing division");
    List<Division> divisions = currentUser.getDivisions();
    if (divisions == null) {
        logger.warn("[" + currentUser + "] No divisions found");
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    } else {//from ww  w .  j  av  a  2s.com
        divisions.replaceAll(Division::getSendingObjectOnlyId);
        logger.info("[" + currentUser + "] Returning user divisions");
        return new ResponseEntity<>(divisions, HttpStatus.OK);
    }
}

From source file:ddf.catalog.transformer.OverlayMetacardTransformer.java

private BufferedImage createTileFromImageAndBoundary(BufferedImage image, List<Vector> boundary) {
    /*/*from www. j  a v a  2s  . c  o  m*/
     * We transform the image by moving the corners and applying
     * transparency so that it looks right when laid down as a north-up
     * rectangular tile.
     */

    // Scaling by latitude so our x and y axes have roughly equal units.
    double lat = boundary.get(0).get(1);
    boundary.replaceAll(v -> scaleByLatitude(v, lat));

    // We are putting the image into a north-up rectangle, so we need
    // to get the minimum rectangle surrounding the boundary.
    List<Vector> boundingBox = calculateBoundingBox(boundary);
    Vector origin = boundingBox.get(0).copy();
    boundary.replaceAll(v -> v.subtract(origin));
    boundingBox.replaceAll(v -> v.subtract(origin));

    // The image may be stretched in weird ways, but we do our best to preserve
    // the resolution by scaling by the width of the image when going from lon/lat
    // to pixel space.
    double scaleFactor = calculateScaleFactor(boundary, image.getWidth());
    boundary.replaceAll(v -> v.multiply(scaleFactor));
    boundingBox.replaceAll(v -> v.multiply(scaleFactor));

    return createImage(image, boundary, (int) boundingBox.get(1).get(0), (int) -boundingBox.get(1).get(1));
}

From source file:eu.esdihumboldt.hale.io.geoserver.rest.AbstractResourceManager.java

private String getRestServiceUrl(String resourcePath) {
    List<String> urlParts = new ArrayList<String>();
    urlParts.add(geoserverUrl.toString());
    urlParts.add(REST_BASE);/*from ww  w . j a  va2 s  .co m*/
    urlParts.add(resourcePath);

    urlParts.replaceAll(urlPart -> normalizeUrlPart(urlPart));
    final String resourceUrl = Joiner.on('/').skipNulls().join(urlParts);
    return Joiner.on(".").skipNulls().join(Arrays.asList(resourceUrl, getFormat()));
}

From source file:com.github.thesmartenergy.sparql.generate.jena.engine.impl.SourcePlanImpl.java

/**
 * {@inheritDoc}/*from  ww  w. ja  v  a2 s  . c o m*/
 */
final public void exec(final List<Var> variables, final List<BindingHashMapOverwrite> values) {
    LOG.debug("exec");
    boolean added = variables.add(var);
    if (!added) {
        throw new SPARQLGenerateException("Variable " + var + " is already" + " bound !");
    }
    // ensure we shunt the LocatorURL
    Set<Locator> toRemove = new HashSet<>();
    for (Iterator<Locator> it = fileManager.locators(); it.hasNext();) {
        Locator loc = it.next();
        if (loc instanceof LocatorURL) {
            toRemove.add(loc);
        }
    }
    for (Locator loc : toRemove) {
        fileManager.remove(loc);
    }
    ensureNotEmpty(variables, values);
    values.replaceAll(new Replacer());
}

From source file:de.steilerdev.myVerein.server.controller.admin.UserManagementController.java

/**
 * This function gathers all users. The function is invoked by GETting the URI /api/admin/user.
 * @param term If this parameter is present, only users who are matching the term within their email, first or last name are returned.
 * @return An HTTP response with a status code, together with the JSON list-object of all users (matching the term, if present), or only an error code if an error occurred.
 *///w  w  w  .  ja  va  2 s .co m
@RequestMapping(produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<User>> getUserList(@RequestParam(required = false) String term,
        @CurrentUser User currentUser) {
    List<User> userList;
    if (term == null || term.isEmpty()) {
        logger.trace("[" + currentUser + "] Retrieving all users");
        userList = userRepository.findAllEmailAndName();
    } else {
        logger.trace("[" + currentUser + "] Retrieving all users using the search term " + term);
        userList = userRepository.findAllEmailAndNameContainingString(term);
    }

    if (userList == null) {
        logger.warn(
                "[" + currentUser + "] Unable to get users" + (term != null ? " matching term " + term : ""));
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        userList.replaceAll(User::getSendingObjectOnlyEmailNameId);
        logger.info(
                "[" + currentUser + "] Returning all users" + (term != null ? " matching term " + term : ""));
        return new ResponseEntity<>(userList, HttpStatus.OK);
    }
}

From source file:de.steilerdev.myVerein.server.controller.admin.DivisionManagementController.java

/**
 * This function gathers the names of all available divisions and returns them. The function is invoked by GETting the URI /api/admin/division
 * @param term A term, that is required to be part of the division name.
 * @return An HTTP response with a status code, together with the JSON list-object of all divisions, or only an error code if an error occurred.
 *//*from  ww  w  .j  a va  2 s. c o m*/
@RequestMapping(produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<Division>> getDivision(@RequestParam(required = false) String term,
        @CurrentUser User currentUser) {
    List<Division> divisions;
    if (term == null || term.isEmpty()) {
        logger.trace("[" + currentUser + "]  Retrieving all divisions");
        divisions = divisionRepository.findAllNames();
    } else {
        logger.trace("[" + currentUser + "]  Retrieving all divisions using the search term " + term);
        divisions = divisionRepository.findAllNamesContainingString(term);
    }

    if (divisions == null) {
        logger.warn("[" + currentUser + "]  Unable to get divisions"
                + (term != null ? " matching term " + term : ""));
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        divisions.replaceAll(Division::getSendingObjectInternalSync);
        logger.info("[" + currentUser + "]  Returning all divisions"
                + (term != null ? " matching term " + term : ""));
        return new ResponseEntity<>(divisions, HttpStatus.OK);
    }
}

From source file:de.steilerdev.myVerein.server.controller.user.MessageController.java

/**
 * This function retrieves all unread messages of a user. The function is invoked bu GETting the URI /api/user/message.
 * @param currentUser The currently logged in user.
 * @return An HTTP response with a status code, together with the JSON list-object of all unread messages, or only an error code if an error occurred.
 *//* ww  w . j  a  v a2 s.  co  m*/
@RequestMapping(produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<Message>> getMessages(@CurrentUser User currentUser,
        @RequestParam(required = false) String all) {
    logger.trace("[{}] Getting unread messages", currentUser);
    List<Message> messages = messageRepository.findAllByPrefixedReceiverIDAndMessageStatus(
            Message.receiverIDForUser(currentUser), Message.MessageStatus.PENDING);
    if (messages == null) {
        logger.debug("[{}] Unable to find any undelivered messages", currentUser);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        messages.parallelStream().forEach(message -> message.setDelivered(currentUser));

        if (all != null && !all.isEmpty()) {
            logger.debug("[{}] Retrieving all messages", currentUser);
            messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus(
                    Message.receiverIDForUser(currentUser), Message.MessageStatus.DELIVERED));
            messages.addAll(messageRepository.findAllByPrefixedReceiverIDAndMessageStatus(
                    Message.receiverIDForUser(currentUser), Message.MessageStatus.READ));
        }

        try {
            messageRepository.save(messages);
            messages.replaceAll(Message::getSendingObjectOnlyId);
            logger.info("[{}] Returning messages", currentUser);
            return new ResponseEntity<>(messages, HttpStatus.OK);
        } catch (IllegalArgumentException e) {
            logger.warn("[" + currentUser + "] Unable to save messages for " + currentUser.getEmail() + ": "
                    + e.getMessage());
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}

From source file:ddf.test.itests.platform.TestSecurity.java

@BeforeExam
public void beforeTest() throws Exception {
    try {//www  .  j  a v a  2  s. c  om
        waitForSystemReady();
        Configuration config = getAdminConfig()
                .getConfiguration("org.codice.ddf.admin.config.policy.AdminConfigPolicy");
        config.setBundleLocation(
                "mvn:ddf.admin.core/admin-core-configpolicy/" + System.getProperty("ddf.version"));
        Dictionary properties = new Hashtable<>();

        List<String> featurePolicies = new ArrayList<>();
        featurePolicies.addAll(Arrays.asList(getDefaultRequiredApps()));
        featurePolicies.addAll(FEATURES_TO_FILTER);
        featurePolicies.replaceAll(featureName -> featureName
                + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");

        List<String> servicePolicies = new ArrayList<>();
        servicePolicies.addAll(SERVICES_TO_FILTER);
        servicePolicies.replaceAll(serviceName -> serviceName
                + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");

        properties.put("featurePolicies", featurePolicies.stream().toArray(String[]::new));
        properties.put("servicePolicies", servicePolicies.stream().toArray(String[]::new));
        config.update(properties);

    } catch (Exception e) {
        LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
    }
}

From source file:de.steilerdev.myVerein.server.controller.user.EventController.java

/**
 * This function gathers all events for the currently logged in user. If lastChanged is stated only events that
 * changed after that moment are returned.
 *
 * @param lastChanged The date of the last changed action, correctly formatted (YYYY-MM-DDTHH:mm:ss)
 * @param currentUser The currently logged in user
 * @return A list of all events for the user that changed since the last changed moment in time (only containing
 * id's)//from   w  ww .ja v a 2s  .  c  o m
 */
@RequestMapping(produces = "application/json", method = RequestMethod.GET)
public ResponseEntity<List<Event>> getAllEventsForUser(@RequestParam(required = false) String lastChanged,
        @CurrentUser User currentUser) {
    List<Event> events;
    if (lastChanged != null && !lastChanged.isEmpty()) {
        logger.debug("[{}] Gathering all user events changed after {}", currentUser, lastChanged);
        LocalDateTime lastChangedTime;
        try {
            lastChangedTime = LocalDateTime.parse(lastChanged, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
        } catch (DateTimeParseException e) {
            logger.warn("[{}] Unable to get all events for user, because the last changed format is wrong: {}",
                    currentUser, e.getLocalizedMessage());
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }
        events = eventRepository.findAllByPrefixedInvitedUserAndLastChangedAfter(
                Event.prefixedUserIDForUser(currentUser), lastChangedTime);
    } else {
        logger.debug("[{}] Gathering all user events", currentUser);
        events = eventRepository.findAllByPrefixedInvitedUser(Event.prefixedUserIDForUser(currentUser));
    }

    if (events == null || events.isEmpty()) {
        logger.warn("[{}] No events to return", currentUser);
        return new ResponseEntity<>(HttpStatus.OK);
    } else {
        logger.info("[{}] Returning {} events", currentUser, events.size());
        events.replaceAll(Event::getSendingObjectOnlyId);
        return new ResponseEntity<>(events, HttpStatus.OK);
    }
}