All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netgrif.application.engine.auth.web.responsebodies.UsersResource Maven / Gradle / Ivy

Go to download

System provides workflow management functions including user, role and data management.

There is a newer version: 6.3.3
Show newest version
package com.netgrif.application.engine.auth.web.responsebodies;


import com.netgrif.application.engine.auth.web.UserController;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;

public class UsersResource extends CollectionModel {

    public static final String SELF_REL_SMALL = "small";
    public static final String SELF_REL_PROFILE = "profile";

    public UsersResource(Collection content, String selfRel) {
        super(content, new ArrayList<>(), null);
        buildLinks(selfRel);
    }

    public UsersResource(Collection content, String selfRel, boolean small) {
        this(content.stream().map(user -> new UserResource(user, small ? SELF_REL_SMALL : SELF_REL_PROFILE))
                .collect(Collectors.toList()), selfRel);
    }

    private void buildLinks(String selfRel) {
        WebMvcLinkBuilder allLink = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder
                .methodOn(UserController.class).getAll(false, null, null, null, null));
        add(selfRel.equalsIgnoreCase("all") ? allLink.withSelfRel() : allLink.withRel("all"));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy