DATAREST-463 - Polishing.
Collapsed if clauses leading to the very same return in RootResourceinformationToAlpsDescriptorConverter. Renamed isExportableProperty(…) to isExportable(…) in JacksonMetadata. Removed commented out code in AssociationLinks. Cleanups in test code. Original pull request: #160.
This commit is contained in:
@@ -337,13 +337,8 @@ public class RootResourceInformationToAlpsDescriptorConverter {
|
||||
public void doWithAssociation(Association<? extends PersistentProperty<?>> association) {
|
||||
|
||||
PersistentProperty<?> property = association.getInverse();
|
||||
final Class<?> propertyType = property.getType();
|
||||
|
||||
if (!jackson.isExportableProperty(property)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!associationLinks.isLinkableAssociation(property)) {
|
||||
if (!jackson.isExported(property) || !associationLinks.isLinkableAssociation(property)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,11 +76,12 @@ public class JacksonMetadata implements Iterable<BeanPropertyDefinition> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given property for a type is avaiaable to be exported, i.e. serialized via Jackson
|
||||
* @param property
|
||||
* Check if a given property for a type is available to be exported, i.e. serialized via Jackson.
|
||||
*
|
||||
* @param property must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public boolean isExportableProperty(PersistentProperty<?> property) {
|
||||
public boolean isExported(PersistentProperty<?> property) {
|
||||
return getDefinitionFor(property) != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ public class AssociationLinks {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ResourceMetadata metadata = mappings.getMappingFor(property.getActualType());
|
||||
ResourceMetadata metadata = mappings.getMappingFor(property.getOwner().getType());
|
||||
|
||||
if (metadata != null && !metadata.isExported(property)) {
|
||||
|
||||
@@ -138,5 +138,4 @@ public class AlpsControllerIntegrationTests extends AbstractControllerIntegratio
|
||||
LinkDiscoverer discoverer = discoverers.getLinkDiscovererFor(MediaType.valueOf(response.getContentType()));
|
||||
return discoverer.findLinkWithRel(rel, response.getContentAsString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,25 +24,16 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
* @see DATAREST-463
|
||||
*/
|
||||
@Entity
|
||||
public class Item {
|
||||
|
||||
@Id @GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private @Id @GeneratedValue Long id;
|
||||
private String name;
|
||||
|
||||
@JsonIgnore
|
||||
@OneToOne
|
||||
private User owner;
|
||||
|
||||
@OneToOne
|
||||
private User manager;
|
||||
|
||||
@OneToOne
|
||||
private User curator;
|
||||
private @JsonIgnore @OneToOne User owner;
|
||||
private @OneToOne User manager, curator;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
* @see DATAREST-463
|
||||
*/
|
||||
public interface ItemRepository extends CrudRepository<Item, Long> {
|
||||
}
|
||||
public interface ItemRepository extends CrudRepository<Item, Long> {}
|
||||
|
||||
@@ -23,50 +23,47 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
* @see DATAREST-463
|
||||
*/
|
||||
@Entity
|
||||
public class User {
|
||||
|
||||
@Id @GeneratedValue
|
||||
private Long id;
|
||||
private @Id @GeneratedValue Long id;
|
||||
private String name;
|
||||
private @JsonIgnore String password;
|
||||
|
||||
private String name;
|
||||
private String[] roles;
|
||||
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
private String[] roles;
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(String... roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
public void setRoles(String... roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
package org.springframework.data.rest.webmvc.jpa;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
/**
|
||||
* @author Greg Turnquist
|
||||
* @author Oliver Gierke
|
||||
* @see DATAREST-463
|
||||
*/
|
||||
@RepositoryRestResource(exported = false)
|
||||
public interface UserRepository extends CrudRepository<User, Long> {
|
||||
}
|
||||
interface UserRepository extends CrudRepository<User, Long> {}
|
||||
|
||||
Reference in New Issue
Block a user