ing
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.loafle.overflow.core.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import com.loafle.overflow.model.infra.InfraHostIP;
|
||||
|
||||
/**
|
||||
* InfraHostIPsSerializer
|
||||
*/
|
||||
public class InfraHostIPsSerializer extends StdSerializer<List<InfraHostIP>> {
|
||||
|
||||
private static final long serialVersionUID = -7842189644539038488L;
|
||||
|
||||
public InfraHostIPsSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public InfraHostIPsSerializer(Class<List<InfraHostIP>> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(List<InfraHostIP> infraHostIPs, JsonGenerator gen, SerializerProvider provider)
|
||||
throws IOException {
|
||||
if (null == infraHostIPs) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (InfraHostIP infraHostIP : infraHostIPs) {
|
||||
infraHostIP.setInfraHost(null);
|
||||
}
|
||||
|
||||
gen.writeObject(infraHostIPs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,10 @@ import java.util.List;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.loafle.overflow.core.json.InfraHostIPsSerializer;
|
||||
import com.loafle.overflow.model.meta.MetaTargetHostType;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonManagedReference;
|
||||
import org.hibernate.annotations.Fetch;
|
||||
import org.hibernate.annotations.FetchMode;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class InfraHost extends Infra {
|
||||
private InfraHostMachine infraHostMachine;
|
||||
private InfraHostOS infraHostOS;
|
||||
|
||||
@JsonManagedReference
|
||||
@JsonSerialize(using = InfraHostIPsSerializer.class)
|
||||
private List<InfraHostIP> infraHostIPs;
|
||||
|
||||
private InfraHost containerInfraHost;
|
||||
|
||||
@@ -4,9 +4,6 @@ import javax.persistence.*;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaIPType;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonBackReference;
|
||||
import org.codehaus.jackson.annotate.JsonManagedReference;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -16,8 +13,6 @@ import java.util.Date;
|
||||
@Table(name = "INFRA_HOST_IP", schema = "public")
|
||||
public class InfraHostIP {
|
||||
private Long id;
|
||||
@JsonBackReference
|
||||
@JsonManagedReference
|
||||
private InfraHost infraHost;
|
||||
private MetaIPType metaIPType;
|
||||
private String address;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.loafle.overflow.model.member;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.loafle.overflow.model.meta.MetaMemberStatus;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user