Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<version>1.5.9.RELEASE</version>
<relativePath></relativePath>
</parent>

Expand Down Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.0.0</version>
<version>1.27.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/*
* Copyright 2017 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
* 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
* 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.
* 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.gclouddatastore.repository;
Expand All @@ -34,6 +31,7 @@ public GcloudDatastoreEntityInformation(Class<T> domainClass) {
@SuppressWarnings("unchecked")
@Override
public ID getId(T entity) {

Class<?> domainClass = getJavaType();
while (domainClass != Object.class) {
for (Field field : domainClass.getDeclaredFields()) {
Expand All @@ -43,7 +41,7 @@ public ID getId(T entity) {
}
catch (IllegalArgumentException | IllegalAccessException e) {
BeanWrapper beanWrapper = PropertyAccessorFactory
.forBeanPropertyAccess(entity);
.forBeanPropertyAccess(entity);
return (ID) beanWrapper.getPropertyValue(field.getName());
}
}
Expand All @@ -56,6 +54,7 @@ public ID getId(T entity) {
@SuppressWarnings("unchecked")
@Override
public Class<ID> getIdType() {

Class<?> domainClass = getJavaType();
while (domainClass != Object.class) {
for (Field field : domainClass.getDeclaredFields()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
/*
* Copyright 2017 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
* 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
* 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.
* 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.gclouddatastore.repository;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;

public class GcloudDatastoreRepositoryConfigurationExtension
extends RepositoryConfigurationExtensionSupport {
public class GcloudDatastoreRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {

private static final String DATASTORE_OPTIONS = "datastoreOptions";

@Override
public String getRepositoryFactoryClassName() {

return GcloudDatastoreRepositoryFactory.class.getName();
}

@Override
protected String getModulePrefix() {

return "gcloudds";
}

@Override
public void postProcess(final BeanDefinitionBuilder builder, final AnnotationRepositoryConfigurationSource config) {

builder.addDependsOn(DATASTORE_OPTIONS);
builder.addPropertyReference(DATASTORE_OPTIONS, DATASTORE_OPTIONS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Object next() {
.newInstance();
unmarshaller.unmarshalToObject(
results.next(), entity);
return entity;
return entity;
}
catch (InstantiationException
| IllegalAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
/*
* Copyright 2017 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
* 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
* 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.
* 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.gclouddatastore.repository;

import java.io.Serializable;

import com.google.cloud.datastore.DatastoreOptions;

import org.springframework.data.repository.Repository;
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.util.Assert;

public class GcloudDatastoreRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
extends RepositoryFactoryBeanSupport<T, S, ID> {

DatastoreOptions datastoreOptions;
private DatastoreOptions datastoreOptions;

public GcloudDatastoreRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
super(repositoryInterface);
this.datastoreOptions = DatastoreOptions.getDefaultInstance();
}

public GcloudDatastoreRepositoryFactoryBean(
Class<? extends T> repositoryInterface,
DatastoreOptions datastoreOptions) {
super(repositoryInterface);
@Override
protected RepositoryFactorySupport createRepositoryFactory() {

return new GcloudDatastoreRepositoryFactory(datastoreOptions);
}

public void setDatastoreOptions(DatastoreOptions datastoreOptions) {

this.datastoreOptions = datastoreOptions;
}

@Override
protected RepositoryFactorySupport createRepositoryFactory() {
return new GcloudDatastoreRepositoryFactory(this.datastoreOptions);
public void afterPropertiesSet() {

Assert.notNull(datastoreOptions, "you must provide DatastoreOptions it cannot be null!");
super.afterPropertiesSet();
}
}
Loading