Java 类com.fasterxml.jackson.annotation.JsonManagedReference 实例源码
项目:minnal
文件:BiDirectionalCollectionResolver.java
@Override
protected void setAttribute(Object pojo, AttributeMetaData attribute, Object value) {
super.setAttribute(pojo, attribute, value);
JsonManagedReference managedReference = attribute.getAnnotation(JsonManagedReference.class);
if (managedReference != null && value != null) {
Class<?> elementType = (Class<?>) attribute.getTypeArguments()[0];
PropertyDescriptor backReference = getManagedBackReference(elementType, managedReference.value());
if (backReference != null) {
Collection collection = (Collection) value;
for (Object object : collection) {
try {
PropertyUtils.setProperty(object, backReference.getName(), pojo);
} catch (Exception e) {
logger.info("Failed while setting the property {} on the class {}", backReference.getName(), value.getClass());
}
}
}
}
}
项目:caratarse-auth
文件:Authorization.java
@OneToMany(mappedBy = "authorization")
@Filters({@Filter(name = "limitByNotDeleted")})
@JsonManagedReference
public List<UserAuthorization> getUserAuthorizations() {
if (userAuthorizations == null) {
userAuthorizations = new LinkedList<UserAuthorization>();
}
return userAuthorizations;
}
项目:eMonocot
文件:Taxon.java
/**
* @return a map of descriptions about the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("descriptions-taxon")
public Set<Description> getDescriptions() {
return descriptions;
}
项目:eMonocot
文件:Taxon.java
/**
* @return the distribution associated with this taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("distribution-taxon")
public Set<Distribution> getDistribution() {
return distribution;
}
项目:eMonocot
文件:Taxon.java
/**
* @return a list of identifiers the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("identifier-taxon")
public Set<Identifier> getIdentifiers() {
return identifiers;
}
项目:eMonocot
文件:Taxon.java
/**
* @return a map of vernacularNames for the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("vernacularNames-taxon")
public Set<VernacularName> getVernacularNames() {
return vernacularNames;
}
项目:eMonocot
文件:Taxon.java
/**
* @return a set of measurements or facts about the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("measurementsOrFacts-taxon")
public Set<MeasurementOrFact> getMeasurementsOrFacts() {
return measurementsOrFacts;
}
项目:powop
文件:Taxon.java
/**
* @return a map of descriptions about the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("descriptions-taxon")
public Set<Description> getDescriptions() {
return descriptions;
}
项目:powop
文件:Taxon.java
/**
* @return the distribution associated with this taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("distribution-taxon")
public Set<Distribution> getDistribution() {
return distribution;
}
项目:powop
文件:Taxon.java
/**
* @return a list of identifiers the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("identifier-taxon")
public Set<Identifier> getIdentifiers() {
return identifiers;
}
项目:powop
文件:Taxon.java
/**
* @return a map of vernacularNames for the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("vernacularNames-taxon")
public Set<VernacularName> getVernacularNames() {
return vernacularNames;
}
项目:powop
文件:Taxon.java
/**
* @return a set of measurements or facts about the taxon
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "taxon", orphanRemoval = true)
@Cascade({ CascadeType.ALL })
@JsonManagedReference("measurementsOrFacts-taxon")
public Set<MeasurementOrFact> getMeasurementsOrFacts() {
return measurementsOrFacts;
}
项目:eHMP
文件:Encounter.java
@JsonManagedReference("encounter-provider")
@JsonView({JSONViews.JDBView.class, JSONViews.WSView.class, JSONViews.EventView.class})
public EncounterProvider getPrimaryProvider() {
if (providers == null) return null;
for (EncounterProvider provider : providers) {
if (provider.getPrimary() != null && provider.getPrimary()) {
return provider;
}
}
return null;
}
项目:eHMP
文件:MedicationAdministration.java
/**
* Not sure what is going on here, but jackson is not serializing this properly
* so for now I'm constructing the objects as needed.
* TODO: need to figure this out!!
**/
@JsonManagedReference("medication-administration-meds")
@JsonIgnore
public List<MedicationAdministrationMed> getMedications() {
if (this.medication == null) {
this.medication = new ArrayList<>();
List<Map<String,Object>> adminMeds = (List<Map<String, Object>>) getProperty("medication");
if (adminMeds != null) {
for (Map<String,Object> adminMed : adminMeds) {
this.medication.add(new MedicationAdministrationMed(adminMed));
}
}
}
return this.medication;
}
项目:eHMP
文件:MedicationAdministration.java
/**
* TODO: Same de-serialization issue as above
* @return
*/
@JsonManagedReference("medication-administration-comment")
@JsonIgnore
public List<MedicationAdministrationComment> getComments() {
if (this.comment == null) {
this.comment = new ArrayList<>();
List<Map<String,Object>> comments = (List<Map<String, Object>>) getProperty("comment");
if (comments != null) {
for (Map<String,Object> c : comments) {
this.comment.add(new MedicationAdministrationComment(c));
}
}
}
return this.comment;
}
项目:json-view
文件:JsonViewSerializer.java
/**
* Returns a boolean indicating whether the provided field is annotated with
* some form of ignore. This method is memoized to speed up execution time
*/
boolean annotatedWithIgnore(Field f) {
return memoizer.ignoreAnnotations(f, () -> {
JsonIgnore jsonIgnore = getAnnotation(f, JsonIgnore.class);
JsonIgnoreProperties classIgnoreProperties = getAnnotation(f.getDeclaringClass(), JsonIgnoreProperties.class);
JsonIgnoreProperties fieldIgnoreProperties = null;
boolean backReferenced = false;
//make sure the referring field didn't specify properties to ignore
if(referringField != null) {
fieldIgnoreProperties = getAnnotation(referringField, JsonIgnoreProperties.class);
}
//make sure the referring field didn't specify a backreference annotation
if(getAnnotation(f, JsonBackReference.class) != null && referringField != null) {
for(Field lastField : getDeclaredFields(referringField.getDeclaringClass())) {
JsonManagedReference fieldManagedReference = getAnnotation(lastField, JsonManagedReference.class);
if(fieldManagedReference != null && lastField.getType().equals(f.getDeclaringClass())) {
backReferenced = true;
break;
}
}
}
return (jsonIgnore != null && jsonIgnore.value()) ||
(classIgnoreProperties != null && Arrays.asList(classIgnoreProperties.value()).contains(f.getName())) ||
(fieldIgnoreProperties != null && Arrays.asList(fieldIgnoreProperties.value()).contains(f.getName())) ||
backReferenced;
});
}
项目:leanbean
文件:Meeting.java
@OneToMany(mappedBy = "meeting", fetch = FetchType.EAGER)
@JsonManagedReference
public Set<Topic> getTopics() {
//Set<Topic> sortedTopics = new TreeSet<Topic>(Topic.TopicVoteComparator);
//sortedTopics.addAll(this.topics);
//return sortedTopics;
return this.topics;
}
项目:QuizUpWinner
文件:JacksonAnnotationIntrospector.java
public String findDeserializationName(AnnotatedField paramAnnotatedField)
{
JsonProperty localJsonProperty = (JsonProperty)paramAnnotatedField.getAnnotation(JsonProperty.class);
if (localJsonProperty != null)
return localJsonProperty.value();
if ((paramAnnotatedField.hasAnnotation(JsonDeserialize.class)) || (paramAnnotatedField.hasAnnotation(JsonView.class)) || (paramAnnotatedField.hasAnnotation(JsonBackReference.class)) || (paramAnnotatedField.hasAnnotation(JsonManagedReference.class)))
return "";
return null;
}
项目:QuizUpWinner
文件:JacksonAnnotationIntrospector.java
public String findDeserializationName(AnnotatedMethod paramAnnotatedMethod)
{
JsonSetter localJsonSetter = (JsonSetter)paramAnnotatedMethod.getAnnotation(JsonSetter.class);
if (localJsonSetter != null)
return localJsonSetter.value();
JsonProperty localJsonProperty = (JsonProperty)paramAnnotatedMethod.getAnnotation(JsonProperty.class);
if (localJsonProperty != null)
return localJsonProperty.value();
if ((paramAnnotatedMethod.hasAnnotation(JsonDeserialize.class)) || (paramAnnotatedMethod.hasAnnotation(JsonView.class)) || (paramAnnotatedMethod.hasAnnotation(JsonBackReference.class)) || (paramAnnotatedMethod.hasAnnotation(JsonManagedReference.class)))
return "";
return null;
}
项目:QuizUpWinner
文件:JacksonAnnotationIntrospector.java
public AnnotationIntrospector.ReferenceProperty findReferenceType(AnnotatedMember paramAnnotatedMember)
{
JsonManagedReference localJsonManagedReference = (JsonManagedReference)paramAnnotatedMember.getAnnotation(JsonManagedReference.class);
if (localJsonManagedReference != null)
return AnnotationIntrospector.ReferenceProperty.managed(localJsonManagedReference.value());
JsonBackReference localJsonBackReference = (JsonBackReference)paramAnnotatedMember.getAnnotation(JsonBackReference.class);
if (localJsonBackReference != null)
return AnnotationIntrospector.ReferenceProperty.back(localJsonBackReference.value());
return null;
}
项目:minnal
文件:BiDirectionalObjectResolver.java
@Override
protected void setAttribute(Object pojo, AttributeMetaData attribute, Object value) {
super.setAttribute(pojo, attribute, value);
JsonManagedReference managedReference = attribute.getAnnotation(JsonManagedReference.class);
if (managedReference != null && value != null) {
PropertyDescriptor backReference = getManagedBackReference(value.getClass(), managedReference.value());
if (backReference != null) {
try {
PropertyUtils.setProperty(value, backReference.getName(), pojo);
} catch (Exception e) {
logger.info("Failed while setting the property {} on the class {}", backReference.getName(), value.getClass());
}
}
}
}
项目:GitHub
文件:Employee.java
@JsonManagedReference
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="employee")
public Set<Customer> getCustomers() {
return this.customers;
}
项目:asura
文件:TUser.java
@JsonManagedReference
public Set<TArticle> getArticles() {
return articles;
}
项目:Spring-MVC-Blueprints
文件:BookedTrip.java
@JsonManagedReference("customer-data")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId", nullable = false)
public CustomerInfo getCustomerInfo() {
return this.customerInfo;
}
项目:Spring-MVC-Blueprints
文件:BookedTrip.java
@JsonManagedReference("booked-data")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tripId", nullable = false)
public Trip getTrip() {
return this.trip;
}
项目:mojito
文件:Drop.java
@JsonManagedReference
public Set<TranslationKit> getTranslationKits() {
return translationKits;
}
项目:Purifinity
文件:AbstractUniversalSyntaxTreeNode.java
@Override
@JsonManagedReference
public final List<UniversalSyntaxTree> getChildren() {
return children;
}
项目:Purifinity
文件:AnalysisRunFileTree.java
@Override
@JsonManagedReference
public List<AnalysisRunFileTree> getChildren() {
return children;
}
项目:eMonocot
文件:Taxon.java
/**
* @param newDescriptions
* Set the descriptions associated with this taxon
*/
@JsonManagedReference("descriptions-taxon")
public void setDescriptions(Set<Description> newDescriptions) {
this.descriptions = newDescriptions;
}
项目:eMonocot
文件:Taxon.java
/**
* @param newDistribution
* Set the distribution associated with this taxon
*/
@JsonManagedReference("distribution-taxon")
public void setDistribution(Set<Distribution> newDistribution) {
this.distribution = newDistribution;
}
项目:eMonocot
文件:Taxon.java
/**
* @param newIdentifiers
* Set the identifiers associated with this taxon
*/
@JsonManagedReference("identifier-taxon")
public void setIdentifiers(Set<Identifier> newIdentifiers) {
this.identifiers = newIdentifiers;
}
项目:eMonocot
文件:Taxon.java
/**
* @param newVernacularNames
* Set the vernacular names for this taxon
*/
@JsonManagedReference("vernacularNames-taxon")
public void setVernacularNames(Set<VernacularName> newVernacularNames) {
this.vernacularNames = newVernacularNames;
}
项目:eMonocot
文件:Taxon.java
/**
* @param newMeasurementsOrFacts
* Set the measurements or facts about this taxon
*/
@JsonManagedReference("measurementsOrFacts-taxon")
public void setMeasurementsOrFacts(
Set<MeasurementOrFact> newMeasurementsOrFacts) {
this.measurementsOrFacts = newMeasurementsOrFacts;
}
项目:powop
文件:Taxon.java
/**
* @param newDescriptions
* Set the descriptions associated with this taxon
*/
@JsonManagedReference("descriptions-taxon")
public void setDescriptions(Set<Description> newDescriptions) {
this.descriptions = newDescriptions;
}
项目:powop
文件:Taxon.java
/**
* @param newDistribution
* Set the distribution associated with this taxon
*/
@JsonManagedReference("distribution-taxon")
public void setDistribution(Set<Distribution> newDistribution) {
this.distribution = newDistribution;
}
项目:powop
文件:Taxon.java
/**
* @param newIdentifiers
* Set the identifiers associated with this taxon
*/
@JsonManagedReference("identifier-taxon")
public void setIdentifiers(Set<Identifier> newIdentifiers) {
this.identifiers = newIdentifiers;
}
项目:powop
文件:Taxon.java
/**
* @param newVernacularNames
* Set the vernacular names for this taxon
*/
@JsonManagedReference("vernacularNames-taxon")
public void setVernacularNames(Set<VernacularName> newVernacularNames) {
this.vernacularNames = newVernacularNames;
}
项目:powop
文件:Taxon.java
/**
* @param newMeasurementsOrFacts
* Set the measurements or facts about this taxon
*/
@JsonManagedReference("measurementsOrFacts-taxon")
public void setMeasurementsOrFacts(
Set<MeasurementOrFact> newMeasurementsOrFacts) {
this.measurementsOrFacts = newMeasurementsOrFacts;
}
项目:eHMP
文件:Encounter.java
@JsonManagedReference("encounter-movement")
public Set<EncounterMovement> getMovements() {
return this.movements;
}
项目:eHMP
文件:Encounter.java
@JsonManagedReference("encounter-provider")
@JsonView({JSONViews.JDBView.class, JSONViews.WSView.class, JSONViews.EventView.class})
public Set<EncounterProvider> getProviders() {
return providers;
}