From 2ec11a99664ec682324a1fd7a5220b9be78b7d59 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 9 Jan 2015 16:39:02 +0100 Subject: [PATCH] DATAREST-436 - Removed obsolete examples and TCK module. --- .../RestExporterExampleRestConfig.java | 70 --------- .../example/RestExporterWebInitializer.java | 46 ------ .../gemfire/GemfireRepositoryConfig.java | 33 ----- .../core/AbstractPersistentEntity.java | 77 ---------- .../rest/example/gemfire/core/Address.java | 82 ----------- .../rest/example/gemfire/core/Customer.java | 138 ------------------ .../gemfire/core/CustomerRepository.java | 50 ------- .../example/gemfire/core/EmailAddress.java | 127 ---------------- .../rest/example/gemfire/core/Product.java | 133 ----------------- .../gemfire/core/ProductRepository.java | 50 ------- .../rest/example/gemfire/order/LineItem.java | 92 ------------ .../rest/example/gemfire/order/Order.java | 119 --------------- .../gemfire/order/OrderRepository.java | 28 ---- .../data/rest/example/jpa/JpaLoader.java | 37 ----- .../rest/example/jpa/JpaRepositoryConfig.java | 64 -------- .../data/rest/example/jpa/Person.java | 114 --------------- .../rest/example/jpa/PersonRepository.java | 47 ------ .../rest/example/jpa/PersonValidator.java | 21 --- .../mongodb/MongoDbRepositoryConfig.java | 32 ---- .../data/rest/example/mongodb/Profile.java | 44 ------ .../example/mongodb/ProfileRepository.java | 11 -- .../data/rest/example/neo4j/Friend.java | 57 -------- .../rest/example/neo4j/FriendRepository.java | 9 -- .../data/rest/example/neo4j/Movie.java | 47 ------ .../rest/example/neo4j/MovieRepository.java | 9 -- .../data/rest/example/neo4j/Neo4jLoader.java | 47 ------ .../example/neo4j/Neo4jRepositoryConfig.java | 52 ------- .../data/rest/example/neo4j/Studio.java | 35 ----- .../rest/example/neo4j/StudioRepository.java | 9 -- .../main/resources/META-INF/persistence.xml | 13 -- .../META-INF/spring/cache-config.xml | 14 -- .../META-INF/spring/security-config.xml | 10 -- .../ValidationMessages_en_US.properties | 1 - .../src/main/resources/logback.xml | 17 --- 34 files changed, 1735 deletions(-) delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterExampleRestConfig.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterWebInitializer.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/GemfireRepositoryConfig.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/AbstractPersistentEntity.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Address.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Customer.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/CustomerRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/EmailAddress.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Product.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/ProductRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/LineItem.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/Order.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/OrderRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaLoader.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaRepositoryConfig.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/Person.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonValidator.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/MongoDbRepositoryConfig.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/Profile.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/ProfileRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Friend.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/FriendRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Movie.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/MovieRepository.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jLoader.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jRepositoryConfig.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Studio.java delete mode 100644 spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/StudioRepository.java delete mode 100644 spring-data-rest-example/src/main/resources/META-INF/persistence.xml delete mode 100644 spring-data-rest-example/src/main/resources/META-INF/spring/cache-config.xml delete mode 100644 spring-data-rest-example/src/main/resources/META-INF/spring/security-config.xml delete mode 100644 spring-data-rest-example/src/main/resources/ValidationMessages_en_US.properties delete mode 100644 spring-data-rest-example/src/main/resources/logback.xml diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterExampleRestConfig.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterExampleRestConfig.java deleted file mode 100644 index 84128e177..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterExampleRestConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.springframework.data.rest.example; - -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.ReloadableResourceBundleMessageSource; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.example.jpa.Person; -import org.springframework.data.rest.example.jpa.PersonValidator; -import org.springframework.data.rest.webmvc.RepositoryLinksResource; -import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceProcessor; - -/** - * @author Jon Brisbin - */ -@SuppressWarnings({"rawtypes"}) -@Configuration -//@ImportResource("classpath:META-INF/spring/security-config.xml") -public class RestExporterExampleRestConfig extends RepositoryRestMvcConfiguration { - - @Bean - public MessageSource messageSource() { - ReloadableResourceBundleMessageSource msgsrc = new ReloadableResourceBundleMessageSource(); - msgsrc.setBasename("/WEB-INF/classes/ValidationMessages"); - msgsrc.setFallbackToSystemLocale(false); - return msgsrc; - } - - @Bean - public PersonValidator beforeCreatePersonValidator() { - return new PersonValidator(); - } - - @Override - protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.setResourceMappingForDomainType(Person.class) - .addResourceMappingFor("lastName") - .setPath("surname"); - } - - @Bean - public ResourceProcessor> personResourceProcessor() { - return new ResourceProcessor>() { - RepositoryRestConfiguration config = config(); - - @Override - public Resource process(Resource resource) { - System.out.println("processing " + resource); - System.out.println("url: " + config.getBaseUri().toString()); - resource.add(new Link("http://host:port/path", "myrel")); - return resource; - } - }; - } - - @Bean - public ResourceProcessor rootLinksResourceProcessor() { - return new ResourceProcessor() { - @Override - public RepositoryLinksResource process(RepositoryLinksResource resource) { - resource.add(new Link("href", "rel")); - return resource; - } - }; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterWebInitializer.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterWebInitializer.java deleted file mode 100644 index b65161dc5..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/RestExporterWebInitializer.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.springframework.data.rest.example; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.springframework.data.rest.example.jpa.JpaRepositoryConfig; -import org.springframework.data.rest.example.mongodb.MongoDbRepositoryConfig; -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -/** - * @author Jon Brisbin - */ -public class RestExporterWebInitializer implements WebApplicationInitializer { - - @Override public void onStartup(ServletContext servletContext) throws ServletException { - AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext(); - rootCtx.register( - JpaRepositoryConfig.class, - MongoDbRepositoryConfig.class - //GemfireRepositoryConfig.class, - //Neo4jRepositoryConfig.class - ); - - servletContext.addListener(new ContextLoaderListener(rootCtx)); - // servletContext.addFilter("springSecurity", DelegatingFilterProxy.class); - // servletContext.getFilterRegistration("springSecurity").addMappingForUrlPatterns( - // EnumSet.of(DispatcherType.REQUEST), - // false, - // "/*" - // ); - - AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext(); - webCtx.register(RestExporterExampleRestConfig.class); - - DispatcherServlet dispatcherServlet = new DispatcherServlet(webCtx); - ServletRegistration.Dynamic reg = servletContext.addServlet("rest-exporter", dispatcherServlet); - reg.setLoadOnStartup(1); - reg.addMapping("/*"); - - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/GemfireRepositoryConfig.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/GemfireRepositoryConfig.java deleted file mode 100644 index 0f9e6d626..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/GemfireRepositoryConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories; - -/** - * Spring JavaConfig configuration class to setup a Spring container and infrastructure components. - * - * @author Oliver Gierke - * @author David Turanski - */ -@Configuration -@ImportResource("classpath:META-INF/spring/cache-config.xml") -@EnableGemfireRepositories -public class GemfireRepositoryConfig { - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/AbstractPersistentEntity.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/AbstractPersistentEntity.java deleted file mode 100644 index 8c9cc7565..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/AbstractPersistentEntity.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import org.springframework.data.annotation.Id; - -/** - * Base class for persistent classes. - * - * @author Oliver Gierke - * @author David Turanski - */ -public class AbstractPersistentEntity { - - @Id - private final Long id; - - /** - * Returns the identifier of the entity. - * - * @return the id - */ - public Long getId() { - return id; - } - - protected AbstractPersistentEntity(Long id) { - this.id = id; - } - - protected AbstractPersistentEntity() { - this.id = null; - } - - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - - if (this == obj) { - return true; - } - - if (this.id == null || obj == null || !(this.getClass().equals(obj.getClass()))) { - return false; - } - - AbstractPersistentEntity that = (AbstractPersistentEntity) obj; - - return this.id.equals(that.getId()); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return id == null ? 0 : id.hashCode(); - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Address.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Address.java deleted file mode 100644 index 5b258ab5b..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Address.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import org.springframework.util.Assert; - -/** - * An address. - * - * @author Oliver Gierke - */ -public class Address { - - private final String street, city, country; - - /** - * Creates a new {@link Address} from the given street, city and country. - * - * @param street must not be {@literal null} or empty. - * @param city must not be {@literal null} or empty. - * @param country must not be {@literal null} or empty. - */ - public Address(String street, String city, String country) { - - Assert.hasText(street, "Street must not be null or empty!"); - Assert.hasText(city, "City must not be null or empty!"); - Assert.hasText(country, "Country must not be null or empty!"); - - this.street = street; - this.city = city; - this.country = country; - } - - /** - * Returns a copy of the current {@link Address} instance which is a new entity in terms of persistence. - * - * @return - */ - public Address getCopy() { - return new Address(this.street, this.city, this.country); - } - - /** - * Returns the street. - * - * @return - */ - public String getStreet() { - return street; - } - - /** - * Returns the city. - * - * @return - */ - public String getCity() { - return city; - } - - /** - * Returns the country. - * - * @return - */ - public String getCountry() { - return country; - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Customer.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Customer.java deleted file mode 100644 index a315cced2..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Customer.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.springframework.data.gemfire.mapping.Region; -import org.springframework.util.Assert; - - -/** - * A customer. - * - * @author Oliver Gierke - * @author David Turanski - */ -@Region -public class Customer extends AbstractPersistentEntity { - private EmailAddress emailAddress; - private String firstname, lastname; - private Set
addresses = new HashSet
(); - - /** - * Creates a new {@link Customer} from the given parameters. - * - * @param id - * the unique id; - * @param emailAddress - * must not be {@literal null} or empty. - * @param firstname - * must not be {@literal null} or empty. - * @param lastname - * must not be {@literal null} or empty. - */ - public Customer(Long id, EmailAddress emailAddress, String firstname, String lastname) { - super(id); - Assert.hasText(firstname); - Assert.hasText(lastname); - Assert.notNull(emailAddress); - - this.firstname = firstname; - this.lastname = lastname; - this.emailAddress = emailAddress; - } - - protected Customer() { - } - - /** - * Adds the given {@link Address} to the {@link Customer}. - * - * @param address - * must not be {@literal null}. - */ - public void add(Address address) { - - Assert.notNull(address); - this.addresses.add(address); - } - - /** - * Returns the firstname of the {@link Customer}. - * - * @return - */ - public String getFirstname() { - return firstname; - } - - /** - * Sets the firstname of the {@link Customer}. - * - * @param firstname - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Returns the lastname of the {@link Customer}. - * - * @return - */ - public String getLastname() { - return lastname; - } - - /** - * Sets the lastname of the {@link Customer}. - * - * @param lastname - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Returns the {@link EmailAddress} of the {@link Customer}. - * - * @return - */ - public EmailAddress getEmailAddress() { - return emailAddress; - } - - /** - * Sets the emailAddress of the {@link Customer}. - * - * @param emailAddress - */ - public void setEmailAddress(EmailAddress emailAddress) { - this.emailAddress = emailAddress; - } - - /** - * Return the {@link Customer}'s addresses. - * - * @return - */ - public Set
getAddresses() { - return Collections.unmodifiableSet(addresses); - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/CustomerRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/CustomerRepository.java deleted file mode 100644 index 4e4631759..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/CustomerRepository.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import java.util.List; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; - -/** - * Repository interface to access {@link Customer}s. - * - * @author Oliver Gierke - * @author David Turanski - */ - -public interface CustomerRepository extends CrudRepository { - - /** - * Finds all {@link Customer}s with the given lastname. - * - * @param lastname - * - * @return - */ - List findByLastname(@Param("lastname") String lastname); - - /** - * Finds the Customer with the given {@link EmailAddress}. - * - * @param emailAddress - * - * @return - */ - Customer findByEmailAddress(@Param("email") EmailAddress emailAddress); - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/EmailAddress.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/EmailAddress.java deleted file mode 100644 index e38195ecb..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/EmailAddress.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import java.util.regex.Pattern; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; - -/** - * Value object to represent email addresses. - * - * @author Oliver Gierke - */ -@JsonSerialize(using = ToStringSerializer.class) -public final class EmailAddress { - - private static final String EMAIL_REGEX = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; - private static final Pattern PATTERN = Pattern.compile(EMAIL_REGEX); - private final String value; - - /** - * Creates a new {@link EmailAddress} from the given {@link String} representation. - * - * @param emailAddress - * must not be {@literal null} or empty. - */ - @JsonCreator - public EmailAddress(String emailAddress) { - Assert.isTrue(isValid(emailAddress), "Invalid email address!"); - this.value = emailAddress; - } - - /** - * Returns whether the given {@link String} is a valid {@link EmailAddress} which means you can safely instantiate - * the - * class. - * - * @param candidate - * - * @return - */ - public static boolean isValid(String candidate) { - return candidate == null ? false : PATTERN.matcher(candidate).matches(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return value; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - - if(this == obj) { - return true; - } - - if(!(obj instanceof EmailAddress)) { - return false; - } - - EmailAddress that = (EmailAddress)obj; - return this.value.equals(that.value); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return value.hashCode(); - } - - @Component - static class EmailAddressToStringConverter implements Converter { - - /* - * (non-Javadoc) - * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) - */ - @Override - public String convert(EmailAddress source) { - return source == null ? null : source.value; - } - } - - @Component - static class StringToEmailAddressConverter implements Converter { - - /* - * (non-Javadoc) - * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) - */ - public EmailAddress convert(String source) { - return StringUtils.hasText(source) ? new EmailAddress(source) : null; - } - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Product.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Product.java deleted file mode 100644 index 98b543856..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/Product.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.gemfire.mapping.Region; -import org.springframework.util.Assert; - - -/** - * A product. - * - * @author Oliver Gierke - * @author David Turanski - */ -@Region -public class Product extends AbstractPersistentEntity { - - private String name, description; - private BigDecimal price; - private Map attributes = new HashMap(); - - /** - * Creates a new {@link Product} with the given name. - * - * @param id - * a unique Id - * @param name - * must not be {@literal null} or empty. - * @param price - * must not be {@literal null} or less than or equal to zero. - */ - public Product(Long id, String name, BigDecimal price) { - this(id, name, price, null); - } - - /** - * Creates a new {@link Product} from the given name and description. - * - * @param id - * a unique Id - * @param name - * must not be {@literal null} or empty. - * @param price - * must not be {@literal null} or less than or equal to zero. - * @param description - */ - @PersistenceConstructor - public Product(Long id, String name, BigDecimal price, String description) { - super(id); - Assert.hasText(name, "Name must not be null or empty!"); - Assert.isTrue(BigDecimal.ZERO.compareTo(price) < 0, "Price must be greater than zero!"); - - this.name = name; - this.price = price; - this.description = description; - } - - protected Product() { - } - - /** - * Sets the attribute with the given name to the given value. - * - * @param name - * must not be {@literal null} or empty. - * @param value - */ - public void setAttribute(String name, String value) { - - Assert.hasText(name); - - if(value == null) { - this.attributes.remove(value); - } else { - this.attributes.put(name, value); - } - } - - /** - * Returns the {@link Product}'s name. - * - * @return - */ - public String getName() { - return name; - } - - /** - * Returns the {@link Product}'s description. - * - * @return - */ - public String getDescription() { - return description; - } - - /** - * Returns all the custom attributes of the {@link Product}. - * - * @return - */ - public Map getAttributes() { - return Collections.unmodifiableMap(attributes); - } - - /** - * Returns the price of the {@link Product}. - * - * @return - */ - public BigDecimal getPrice() { - return price; - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/ProductRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/ProductRepository.java deleted file mode 100644 index 484acd3c9..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/core/ProductRepository.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.core; - -import java.util.List; - -import org.springframework.data.gemfire.repository.Query; -import org.springframework.data.repository.CrudRepository; - - -/** - * Repository interface to access {@link Product}s. - * - * @author Oliver Gierke - * @author David TuranskiGem - */ -public interface ProductRepository extends CrudRepository { - - /** - * Returns a list of {@link Product}s having a description which contains the given snippet. - * @param the search string - * @return - */ - - List findByDescriptionContaining(String description); - - /** - * Returns all {@link Product}s having the given attribute value. - * @param attribute - * @param value - * @return - */ - @Query("SELECT * FROM /Product where attributes[$1] = $2") - List findByAttributes(String key, String value); - - List findByName(String name); -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/LineItem.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/LineItem.java deleted file mode 100644 index f0dba2ee6..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/LineItem.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.order; - -import java.math.BigDecimal; - -import org.springframework.data.rest.example.gemfire.core.Product; -import org.springframework.util.Assert; - -/** - * @author Oliver Gierke - */ -public class LineItem { - - private BigDecimal price; - private int amount; - private Long productId; - - /** - * Creates a new {@link LineItem} for the given {@link Product}. - * @param product must not be {@literal null}. - */ - public LineItem(Product product) { - this(product, 1); - } - - /** - * Creates a new {@link LineItem} for the given {@link Product} and amount. - * @param product must not be {@literal null}. - * @param amount - */ - public LineItem(Product product, int amount) { - Assert.notNull(product, "The given Product must not be null!"); - Assert.isTrue(amount > 0, "The amount of Products to be bought must be greater than 0!"); - - this.productId = product.getId(); - this.amount = amount; - this.price = product.getPrice(); - } - - protected LineItem() { - } - - /** - * Returns the id of the {@link Product} the {@link LineItem} refers to. - * - * @return - */ - public Long getProductId() { - return productId; - } - - /** - * Returns the amount of {@link Product}s to be ordered. - * - * @return - */ - public int getAmount() { - return amount; - } - - /** - * Returns the price a single unit of the {@link LineItem}'s product. - * - * @return the price - */ - public BigDecimal getUnitPrice() { - return price; - } - - /** - * Returns the total for the {@link LineItem}. - * - * @return - */ - public BigDecimal getTotal() { - return price.multiply(BigDecimal.valueOf(amount)); - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/Order.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/Order.java deleted file mode 100644 index 34edba895..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/Order.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.order; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.springframework.data.gemfire.mapping.Region; -import org.springframework.data.rest.example.gemfire.core.AbstractPersistentEntity; -import org.springframework.data.rest.example.gemfire.core.Address; -import org.springframework.data.rest.example.gemfire.core.Customer; -import org.springframework.util.Assert; - -/** - * @author Oliver Gierke - * @author David Turanski - */ -@Region -public class Order extends AbstractPersistentEntity { - - private Long customerId; - private Address billingAddress; - private Address shippingAddress; - private Set lineItems = new HashSet(); - - /** - * Creates a new {@link Order} for the given {@link Customer}. - * - * @param customer - * must not be {@literal null}. - */ - public Order(Long id, Long customerId, Address shippingAddress) { - super(id); - Assert.notNull(customerId); - Assert.notNull(shippingAddress); - - this.customerId = customerId; - this.shippingAddress = shippingAddress; - } - - protected Order() { - } - - /** - * Adds the given {@link LineItem} to the {@link Order}. - * - * @param lineItem - */ - public void add(LineItem lineItem) { - this.lineItems.add(lineItem); - } - - /** - * Returns the id of the {@link Customer} who placed the {@link Order}. - * - * @return - */ - public Long getCustomerId() { - return customerId; - } - - /** - * Returns the billing {@link Address} for this order. - * - * @return - */ - public Address getBillingAddress() { - return billingAddress != null ? billingAddress : shippingAddress; - } - - /** - * Returns the shipping {@link Address} for this order; - * - * @return - */ - public Address getShippingAddress() { - return shippingAddress; - } - - /** - * Returns all {@link LineItem}s currently belonging to the {@link Order}. - * - * @return - */ - public Set getLineItems() { - return Collections.unmodifiableSet(lineItems); - } - - /** - * Returns the total of the {@link Order}. - * - * @return - */ - public BigDecimal getTotal() { - - BigDecimal total = BigDecimal.ZERO; - - for(LineItem item : lineItems) { - total = total.add(item.getTotal()); - } - - return total; - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/OrderRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/OrderRepository.java deleted file mode 100644 index 8d550334d..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/gemfire/order/OrderRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2012 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.gemfire.order; - -import java.util.List; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Oliver Gierke - * @author David Turanski - */ -public interface OrderRepository extends CrudRepository { - List findByCustomerId(Long customerId); -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaLoader.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaLoader.java deleted file mode 100644 index 28e18b686..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaLoader.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.springframework.data.rest.example.jpa; - -import java.util.Arrays; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Jon Brisbin - */ -public class JpaLoader { - - private final static Logger LOG = LoggerFactory.getLogger(JpaLoader.class); - @Autowired - PersonRepository people; - - @Transactional - public void loadData() { - Person billyBob = people.save(new Person("Billy Bob", "Thornton")); - LOG.info("Saved {}", billyBob); - Person john = people.save(new Person("John", "Doe")); - LOG.info("Saved {}", john); - Person jane = people.save(new Person("Jane", "Doe")); - LOG.info("Saved {}", jane); - john.setSiblings(Arrays.asList(jane)); - john.setFather(billyBob); - jane.setSiblings(Arrays.asList(john)); - jane.setFather(billyBob); - - people.save(Arrays.asList(john, jane)); - - LOG.info("Person count: {}", people.count()); - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaRepositoryConfig.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaRepositoryConfig.java deleted file mode 100644 index 7c60a5376..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/JpaRepositoryConfig.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.springframework.data.rest.example.jpa; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.orm.jpa.JpaDialect; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.Database; -import org.springframework.orm.jpa.vendor.HibernateJpaDialect; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Jon Brisbin - */ -@Configuration -@ComponentScan(basePackageClasses = JpaRepositoryConfig.class) -@EnableJpaRepositories -@EnableTransactionManagement -public class JpaRepositoryConfig { - - @Bean public DataSource dataSource() { - EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); - return builder.setType(EmbeddedDatabaseType.HSQL).build(); - } - - @Bean public EntityManagerFactory entityManagerFactory() { - HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - vendorAdapter.setDatabase(Database.HSQL); - vendorAdapter.setGenerateDdl(true); - - LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); - factory.setJpaVendorAdapter(vendorAdapter); - factory.setPackagesToScan(getClass().getPackage().getName()); - factory.setDataSource(dataSource()); - - factory.afterPropertiesSet(); - - return factory.getObject(); - } - - @Bean public JpaDialect jpaDialect() { - return new HibernateJpaDialect(); - } - - @Bean public PlatformTransactionManager transactionManager() { - JpaTransactionManager txManager = new JpaTransactionManager(); - txManager.setEntityManagerFactory(entityManagerFactory()); - return txManager; - } - - @Bean(initMethod = "loadData") public JpaLoader jpaLoader() { - return new JpaLoader(); - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/Person.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/Person.java deleted file mode 100644 index ccc227062..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/Person.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.springframework.data.rest.example.jpa; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.PrePersist; -import javax.validation.constraints.NotNull; - -import org.springframework.data.rest.core.annotation.Description; -import org.springframework.data.rest.core.annotation.RestResource; - -/** - * An entity that represents a person. - * - * @author Jon Brisbin - */ -@Entity -public class Person { - - private Long id; - private @Description("A person's first name") String firstName; - private @Description("A person's last name") @NotNull String lastName; - private @Description("Timestamp this person object was created") Date created; - private @Description("A person's siblings") @RestResource(exported = false) List siblings = Collections - .emptyList(); - private Person father; - - public Person() {} - - public Person(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public Person addSibling(Person p) { - if (siblings == Collections.EMPTY_LIST) { - siblings = new ArrayList(); - } - siblings.add(p); - return this; - } - - @ManyToMany(fetch = FetchType.LAZY) - public List getSiblings() { - return siblings; - } - - public void setSiblings(List siblings) { - this.siblings = siblings; - } - - @ManyToOne - public Person getFather() { - return father; - } - - public void setFather(Person father) { - this.father = father; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) {} - - @PrePersist - private void prePersist() { - this.created = Calendar.getInstance().getTime(); - } - - @Override - public String toString() { - return "Person{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' - + ", siblings=[" + siblings.size() + "]" + ", father=" + father + ", created=" + created + '}'; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonRepository.java deleted file mode 100644 index 4f5cf2407..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.example.jpa; - -import java.util.Date; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RestResource; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.format.annotation.DateTimeFormat.ISO; - -/** - * A repository to manage {@link Person}s. - * - * @author Jon Brisbin - */ -@RestResource(rel = "people", path = "people") -public interface PersonRepository extends PagingAndSortingRepository { - - @RestResource(rel = "firstname", path = "firstname") - Page findByFirstName(@Param("firstName") String firstName, Pageable pageable); - - Person findFirstPersonByFirstName(@Param("firstName") String firstName); - - Page findByCreatedGreaterThan(@Param("date") Date date, Pageable pageable); - - @Query("select p from Person p where p.created > :date") - Page findByCreatedUsingISO8601Date(@Param("date") @DateTimeFormat(iso = ISO.DATE_TIME) Date date, - Pageable pageable); -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonValidator.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonValidator.java deleted file mode 100644 index 0dfb36594..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/jpa/PersonValidator.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.springframework.data.rest.example.jpa; - -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; -import org.springframework.validation.Validator; - -/** - * @author Jon Brisbin - */ -public class PersonValidator implements Validator { - - @Override public boolean supports(Class clazz) { - return Person.class.isAssignableFrom(clazz); - } - - @Override public void validate(Object target, Errors errors) { - ValidationUtils.rejectIfEmpty(errors, "firstName", "not.blank"); - ValidationUtils.rejectIfEmpty(errors, "lastName", "not.blank"); - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/MongoDbRepositoryConfig.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/MongoDbRepositoryConfig.java deleted file mode 100644 index c83989f29..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/MongoDbRepositoryConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.springframework.data.rest.example.mongodb; - -import java.net.UnknownHostException; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.mongodb.MongoDbFactory; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.SimpleMongoDbFactory; -import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; - -import com.mongodb.Mongo; - -/** - * @author Jon Brisbin - */ -@Configuration -@ComponentScan -@EnableMongoRepositories -public class MongoDbRepositoryConfig { - - @Bean - public MongoDbFactory mongoDbFactory() throws UnknownHostException { - return new SimpleMongoDbFactory(new Mongo("localhost"), "spring-data-rest-example"); - } - - @Bean - public MongoTemplate mongoTemplate() throws UnknownHostException { - return new MongoTemplate(mongoDbFactory()); - } -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/Profile.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/Profile.java deleted file mode 100644 index 724b2d388..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/Profile.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.springframework.data.rest.example.mongodb; - -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Document; - -/** - * @author Jon Brisbin - */ -@Document -public class Profile { - - @Id - private String id; - private Long person; - private String type; - - public String getId() { - return id; - } - - public Profile setId(String id) { - this.id = id; - return this; - } - - public Long getPerson() { - return person; - } - - public Profile setPerson(Long person) { - this.person = person; - return this; - } - - public String getType() { - return type; - } - - public Profile setType(String type) { - this.type = type; - return this; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/ProfileRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/ProfileRepository.java deleted file mode 100644 index 94aed6e78..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/mongodb/ProfileRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.springframework.data.rest.example.mongodb; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.rest.core.annotation.RestResource; - -/** - * @author Jon Brisbin - */ -@RestResource(exported = true) -public interface ProfileRepository extends CrudRepository { -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Friend.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Friend.java deleted file mode 100644 index 402168dff..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Friend.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import java.util.Set; - -import org.neo4j.graphdb.Direction; -import org.springframework.data.neo4j.annotation.GraphId; -import org.springframework.data.neo4j.annotation.NodeEntity; -import org.springframework.data.neo4j.annotation.RelatedTo; - -/** - * @author Jon Brisbin - */ -@NodeEntity -public class Friend { - - @GraphId - private Long id; - private String name; - @RelatedTo(type = "BFF", direction = Direction.INCOMING) - private Set friends; - - protected Friend() { - } - - public Friend(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Set getFriends() { - return friends; - } - - public void setFriends(Set friends) { - this.friends = friends; - } - - @Override public String toString() { - return "Friend{" + - "id=" + id + - ", name='" + name + '\'' + - ", friends=[" + (null != friends ? friends.size() : 0) + "]" + - '}'; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/FriendRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/FriendRepository.java deleted file mode 100644 index 0a3edbc1a..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/FriendRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import org.springframework.data.neo4j.repository.GraphRepository; - -/** - * @author Jon Brisbin - */ -public interface FriendRepository extends GraphRepository { -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Movie.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Movie.java deleted file mode 100644 index adb7411b6..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Movie.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import org.springframework.data.neo4j.annotation.GraphId; -import org.springframework.data.neo4j.annotation.NodeEntity; -import org.springframework.data.neo4j.annotation.RelatedTo; - -/** - * @author Jon Brisbin - */ -@NodeEntity -public class Movie { - - @GraphId - private Long id; - private String name; - @RelatedTo(enforceTargetType = true) - private Studio studio; - - public Movie() { - } - - public Movie(String name, Studio studio) { - this.name = name; - this.studio = studio; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Studio getStudio() { - return studio; - } - - public void setStudio(Studio studio) { - this.studio = studio; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/MovieRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/MovieRepository.java deleted file mode 100644 index b94383073..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/MovieRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import org.springframework.data.neo4j.repository.GraphRepository; - -/** - * @author Jon Brisbin - */ -public interface MovieRepository extends GraphRepository { -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jLoader.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jLoader.java deleted file mode 100644 index c19c5fbfa..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import java.util.HashSet; -import java.util.Set; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Jon Brisbin - */ -public class Neo4jLoader { - - private static final Logger LOG = LoggerFactory.getLogger(Neo4jLoader.class); - @Autowired - private FriendRepository friends; - @Autowired - private MovieRepository movies; - @Autowired - private StudioRepository studios; - - @SuppressWarnings({"unchecked"}) - @Transactional - public void loadData() { - Friend bob = new Friend("Bob"); - Friend dean = new Friend("Dean"); - Friend jim = new Friend("Jim"); - - Set friends = new HashSet(); - friends.add(dean); - friends.add(jim); - - bob.setFriends(friends); - - this.friends.save(bob); - - LOG.info("Loaded {}", bob); - - Studio studio = studios.save(new Studio("MGM")); - Movie wizardOfOz = movies.save(new Movie("The Wizard of Oz", studio)); - - LOG.info("Loaded {} and {}", studio, wizardOfOz); - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jRepositoryConfig.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jRepositoryConfig.java deleted file mode 100644 index 9e822e38c..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Neo4jRepositoryConfig.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import java.io.File; -import java.io.IOException; - -import org.neo4j.kernel.EmbeddedGraphDatabase; -import org.neo4j.kernel.impl.util.FileUtils; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.config.EnableNeo4jRepositories; -import org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean; -import org.springframework.data.neo4j.support.Neo4jExceptionTranslator; -import org.springframework.data.neo4j.support.Neo4jTemplate; -import org.springframework.data.neo4j.support.mapping.Neo4jMappingContext; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Jon Brisbin - */ -@Configuration -@EnableTransactionManagement -@EnableNeo4jRepositories(basePackages = "org.springframework.data.rest.example.neo4j") -public class Neo4jRepositoryConfig { - - static final String DB_PATH = "db/neo4j-test-db"; - - @Bean(destroyMethod = "shutdown") public EmbeddedGraphDatabase graphDatabaseService() throws IOException { - FileUtils.deleteRecursively(new File(DB_PATH)); - return new EmbeddedGraphDatabase(DB_PATH); - } - - @Bean public Neo4jTemplate neo4jTemplate() throws IOException { - return new Neo4jTemplate(graphDatabaseService()); - } - - @Bean public Neo4jMappingContext neo4jMappingContext() { - return new Neo4jMappingContext(); - } - - @Bean public JtaTransactionManagerFactoryBean transactionManager() throws Exception { - return new JtaTransactionManagerFactoryBean(graphDatabaseService()); - } - - @Bean public Neo4jExceptionTranslator exceptionTranslator() { - return new Neo4jExceptionTranslator(); - } - - @Bean(initMethod = "loadData") public Neo4jLoader neo4jLoader() { - return new Neo4jLoader(); - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Studio.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Studio.java deleted file mode 100644 index 1d4a68f16..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/Studio.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import org.springframework.data.neo4j.annotation.GraphId; -import org.springframework.data.neo4j.annotation.NodeEntity; - -/** - * @author Jon Brisbin - */ -@NodeEntity -public class Studio { - - @GraphId - private Long id; - private String name; - - public Studio() { - } - - public Studio(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/StudioRepository.java b/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/StudioRepository.java deleted file mode 100644 index f415b2221..000000000 --- a/spring-data-rest-example/src/main/java/org/springframework/data/rest/example/neo4j/StudioRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.data.rest.example.neo4j; - -import org.springframework.data.neo4j.repository.GraphRepository; - -/** - * @author Jon Brisbin - */ -public interface StudioRepository extends GraphRepository { -} diff --git a/spring-data-rest-example/src/main/resources/META-INF/persistence.xml b/spring-data-rest-example/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index a92748d1c..000000000 --- a/spring-data-rest-example/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-data-rest-example/src/main/resources/META-INF/spring/cache-config.xml b/spring-data-rest-example/src/main/resources/META-INF/spring/cache-config.xml deleted file mode 100644 index a991aebfc..000000000 --- a/spring-data-rest-example/src/main/resources/META-INF/spring/cache-config.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/spring-data-rest-example/src/main/resources/META-INF/spring/security-config.xml b/spring-data-rest-example/src/main/resources/META-INF/spring/security-config.xml deleted file mode 100644 index 96a6fa0f3..000000000 --- a/spring-data-rest-example/src/main/resources/META-INF/spring/security-config.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/spring-data-rest-example/src/main/resources/ValidationMessages_en_US.properties b/spring-data-rest-example/src/main/resources/ValidationMessages_en_US.properties deleted file mode 100644 index 0b32fad66..000000000 --- a/spring-data-rest-example/src/main/resources/ValidationMessages_en_US.properties +++ /dev/null @@ -1 +0,0 @@ -not.blank = Field {1} cannot be blank \ No newline at end of file diff --git a/spring-data-rest-example/src/main/resources/logback.xml b/spring-data-rest-example/src/main/resources/logback.xml deleted file mode 100644 index 905c91963..000000000 --- a/spring-data-rest-example/src/main/resources/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - \ No newline at end of file