SUPPORT-9122: return ReferenceEntity and add deserializer
This commit is contained in:
parent
80eca20532
commit
fd028c934a
4 changed files with 66 additions and 6 deletions
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import ervu_business_metrics.model.deserializer.ReferenceEntityDeserializer;
|
||||
|
||||
/**
|
||||
* @author Adel Kalimullin
|
||||
|
|
@ -22,7 +24,8 @@ public class AccountData {
|
|||
private String workMail;
|
||||
private boolean esiaAccount;
|
||||
@JsonProperty("user-domain")
|
||||
private String userDomainId;
|
||||
@JsonDeserialize(using = ReferenceEntityDeserializer.class)
|
||||
private ReferenceEntity userDomain;
|
||||
private List<String> roles;
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -113,12 +116,12 @@ public class AccountData {
|
|||
this.esiaAccount = esiaAccount;
|
||||
}
|
||||
|
||||
public String getUserDomainId() {
|
||||
return userDomainId;
|
||||
public ReferenceEntity getUserDomain() {
|
||||
return userDomain;
|
||||
}
|
||||
|
||||
public void setUserDomainId(String userDomainId) {
|
||||
this.userDomainId = userDomainId;
|
||||
public void setUserDomain(ReferenceEntity userDomain) {
|
||||
this.userDomain = userDomain;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package ervu_business_metrics.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
/**
|
||||
* @author Adel Kalimullin
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ReferenceEntity {
|
||||
private String id;
|
||||
|
||||
public ReferenceEntity(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package ervu_business_metrics.model.deserializer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JacksonException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import ervu_business_metrics.model.ReferenceEntity;
|
||||
|
||||
/**
|
||||
* @author Adel Kalimullin
|
||||
*/
|
||||
public class ReferenceEntityDeserializer extends JsonDeserializer<ReferenceEntity> {
|
||||
|
||||
@Override
|
||||
public ReferenceEntity deserialize(JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext) throws IOException, JacksonException {
|
||||
JsonNode node = jsonParser.readValueAsTree();
|
||||
|
||||
if (node.isTextual()) {
|
||||
return new ReferenceEntity(node.asText());
|
||||
}
|
||||
else if (node.isObject()) {
|
||||
JsonNode idNode = node.get("id");
|
||||
if (idNode != null && idNode.isTextual()) {
|
||||
return new ReferenceEntity(idNode.asText());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ public class AccountDataProcessor implements DataProcessor<AccountData> {
|
|||
record.setFio(data.getFio());
|
||||
record.setWorkMail(data.getWorkMail());
|
||||
record.setEsiaAccount(data.isEsiaAccount());
|
||||
record.setDomainId(data.getUserDomainId());
|
||||
record.setDomainId(data.getUserDomain().getId());
|
||||
|
||||
if (existingIds.contains(data.getId())) {
|
||||
accountRecordsToUpdate.add(record);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue