Add avatarUrl on UserListingModel
This commit is contained in:
parent
fcd24fd907
commit
d6970cc49a
|
@ -15,7 +15,7 @@ import java.util.*;
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "userInfo",
|
name = "userInfo",
|
||||||
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}),
|
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials"), @NamedAttributeNode("additionalinfo")}),
|
||||||
})
|
})
|
||||||
public class UserInfo implements DataEntity<UserInfo, UUID> {
|
public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package eu.eudat.models.data.userinfo;
|
package eu.eudat.models.data.userinfo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.entities.UserRole;
|
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class UserListingModel implements DataModel<eu.eudat.data.entities.UserInfo, UserListingModel> {
|
public class UserListingModel implements DataModel<eu.eudat.data.entities.UserInfo, UserListingModel> {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(UserListingModel.class);
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String email;
|
private String email;
|
||||||
|
@ -19,6 +23,7 @@ public class UserListingModel implements DataModel<eu.eudat.data.entities.UserIn
|
||||||
private Date lastloggedin;
|
private Date lastloggedin;
|
||||||
//private String additionalinfo;
|
//private String additionalinfo;
|
||||||
private List<Integer> appRoles;
|
private List<Integer> appRoles;
|
||||||
|
private String avatarUrl;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -83,6 +88,12 @@ public class UserListingModel implements DataModel<eu.eudat.data.entities.UserIn
|
||||||
this.appRoles = appRoles;
|
this.appRoles = appRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAvatarUrl() {
|
||||||
|
return avatarUrl;
|
||||||
|
}
|
||||||
|
public void setAvatarUrl(String avatarUrl) {
|
||||||
|
this.avatarUrl = avatarUrl;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public UserListingModel fromDataModel(UserInfo entity) {
|
public UserListingModel fromDataModel(UserInfo entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
|
@ -94,6 +105,12 @@ public class UserListingModel implements DataModel<eu.eudat.data.entities.UserIn
|
||||||
this.lastloggedin = entity.getLastloggedin();
|
this.lastloggedin = entity.getLastloggedin();
|
||||||
// this.additionalinfo = entity.getAdditionalinfo();
|
// this.additionalinfo = entity.getAdditionalinfo();
|
||||||
this.appRoles = entity.getUserRoles().stream().map(item -> item.getRole()).collect(Collectors.toList());
|
this.appRoles = entity.getUserRoles().stream().map(item -> item.getRole()).collect(Collectors.toList());
|
||||||
|
try {
|
||||||
|
Map<String, Object> additionalInfo = new ObjectMapper().readValue(entity.getAdditionalinfo(), HashMap.class);
|
||||||
|
this.avatarUrl = (String) additionalInfo.get("avatarUrl");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue