Skip to content

Commit 77820a6

Browse files
noubasenoubase
noubase
authored and
noubase
committed
small fixes
1 parent 9fbb398 commit 77820a6

22 files changed

+202
-49
lines changed

core-crud/core-crud.iml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:3.2.7.RELEASE" level="project" />
3636
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.7.RELEASE" level="project" />
3737
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.0.3" level="project" />
38-
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:1.8.0.RC1" level="project" />
38+
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:1.8.0.RELEASE" level="project" />
3939
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.1.7.RELEASE" level="project" />
4040
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
4141
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jcl-over-slf4j:1.7.12" level="project" />
42-
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.11.0.RC1" level="project" />
42+
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.11.0.RELEASE" level="project" />
4343
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.14" level="project" />
4444
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator-annotation-processor:5.2.1.Final" level="project" />
4545
<orderEntry type="library" name="Maven: com.github.fge:json-patch:1.10.1" level="project" />

core-crud/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@
9191
<dependency>
9292
<groupId>org.springframework.data</groupId>
9393
<artifactId>spring-data-mongodb</artifactId>
94-
<version>1.8.0.RC1</version>
94+
<version>1.8.0.RELEASE</version>
9595
</dependency>
9696
<dependency>
9797
<groupId>org.springframework.data</groupId>
9898
<artifactId>spring-data-commons</artifactId>
99-
<version>1.11.0.RC1</version>
99+
<version>1.11.0.RELEASE</version>
100100
</dependency>
101101

102102
<!-- Utils -->

core-crud/src/main/java/com/noubase/core/crud/contoller/CRUDController.java core-crud/src/main/java/com/noubase/core/crud/contoller/ResourceController.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.noubase.core.crud.model.Headers;
1313
import com.noubase.core.crud.model.Pager;
1414
import com.noubase.core.crud.model.ResourceRequest;
15-
import com.noubase.core.crud.repository.CRUDRepository;
15+
import com.noubase.core.crud.repository.ResourceRepository;
1616
import com.noubase.core.crud.util.DomainUtil;
1717
import com.noubase.core.crud.validation.CreateResource;
1818
import com.noubase.core.util.AnnotationUtil;
@@ -43,23 +43,22 @@
4343
/**
4444
* Created by rshuper on 23.07.15.
4545
*/
46-
public abstract class CRUDController<T extends Persistable<ID>, ID extends Serializable> {
46+
public abstract class ResourceController<T extends Persistable<ID>, ID extends Serializable> {
4747

4848
private int maxCollectionSize;
4949

50-
51-
@Value("${crud.collections.max_size ?: 10}")
50+
@Value("${crud.collections.max_size: 10}")
5251
public void setMaxCollectionSize(int value) {
53-
this.maxCollectionSize = value; // todo: investigate
52+
this.maxCollectionSize = value;
5453
}
5554

5655
private final Logger logger;
57-
private final CRUDRepository<T, ID> repo;
56+
private final ResourceRepository<T, ID> repo;
5857
private final Class<T> tClass;
5958
@NotNull
60-
private final Class<? extends CRUDController<T, ID>> controllerClass;
59+
private final Class<? extends ResourceController<T, ID>> controllerClass;
6160

62-
protected CRUDController(Class<T> tClass, @NotNull Class<? extends CRUDController<T, ID>> controllerClass, CRUDRepository<T, ID> repo) {
61+
protected ResourceController(Class<T> tClass, @NotNull Class<? extends ResourceController<T, ID>> controllerClass, ResourceRepository<T, ID> repo) {
6362
this.tClass = tClass;
6463
this.controllerClass = controllerClass;
6564
this.repo = repo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.noubase.core.crud.domain;
2+
3+
import org.springframework.data.annotation.CreatedDate;
4+
import org.springframework.data.annotation.Id;
5+
import org.springframework.data.mongodb.core.index.Indexed;
6+
7+
import java.io.Serializable;
8+
import java.util.Date;
9+
10+
/**
11+
* Created by rshuper on 07.09.15.
12+
*/
13+
public class BindResource<T extends Serializable> {
14+
@Id
15+
private T id;
16+
17+
@Indexed
18+
@CreatedDate
19+
private Date created;
20+
21+
public BindResource() {
22+
}
23+
24+
public T getId() {
25+
return id;
26+
}
27+
28+
public void setId(T id) {
29+
this.id = id;
30+
}
31+
32+
public Date getCreated() {
33+
return created;
34+
}
35+
36+
public void setCreated(Date created) {
37+
this.created = created;
38+
}
39+
}

core-crud/src/main/java/com/noubase/core/crud/repository/CustomMongoRepositoryFactoryBean.java core-crud/src/main/java/com/noubase/core/crud/repository/ResourceMongoRepositoryFactoryBean.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Created by rshuper on 13.08.15.
1313
*/
14-
public class CustomMongoRepositoryFactoryBean<T extends CRUDRepository<S, ID> & PatchableRepository, S extends Persistable<ID>, ID extends Serializable>
14+
public class ResourceMongoRepositoryFactoryBean<T extends ResourceRepository<S, ID> & PatchableRepository, S extends Persistable<ID>, ID extends Serializable>
1515
extends MongoRepositoryFactoryBean<T, S, ID> {
1616

1717
@Autowired

core-crud/src/main/java/com/noubase/core/crud/repository/CRUDRepository.java core-crud/src/main/java/com/noubase/core/crud/repository/ResourceRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Created by rshuper on 11.08.15.
1818
*/
1919
@NoRepositoryBean
20-
public interface CRUDRepository<T extends Persistable<ID>, ID extends Serializable> extends MongoRepository<T, ID> {
20+
public interface ResourceRepository<T extends Persistable<ID>, ID extends Serializable> extends MongoRepository<T, ID> {
2121

2222
Page<T> findAll(CollectionRequest<T> request);
2323

core-crud/src/main/java/com/noubase/core/crud/repository/CRUDRepositoryImpl.java core-crud/src/main/java/com/noubase/core/crud/repository/ResourceRepositoryImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
/**
3838
* Created by rshuper on 11.08.15.
3939
*/
40-
public class CRUDRepositoryImpl<T extends Persistable<ID>, ID extends Serializable> extends SimpleMongoRepository<T, ID>
41-
implements CRUDRepository<T, ID>, PatchableRepository {
40+
public class ResourceRepositoryImpl<T extends Persistable<ID>, ID extends Serializable> extends SimpleMongoRepository<T, ID>
41+
implements ResourceRepository<T, ID>, PatchableRepository {
4242

4343
@NotNull
4444
private final MongoOperations mongoOperations;
@@ -52,7 +52,7 @@ public void setJsonPatcher(@NotNull JsonPatcher jsonPatcher) {
5252
this.jsonPatcher = jsonPatcher;
5353
}
5454

55-
public CRUDRepositoryImpl(@NotNull MongoEntityInformation<T, ID> metadata, @NotNull MongoOperations mongoOperations) {
55+
public ResourceRepositoryImpl(@NotNull MongoEntityInformation<T, ID> metadata, @NotNull MongoOperations mongoOperations) {
5656
super(metadata, mongoOperations);
5757
this.mongoOperations = mongoOperations;
5858
this.metadata = metadata;

core-crud/src/test/java/com/noubase/core/crud/AbstractIntegrationTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import com.mongodb.WriteConcern;
66
import com.noubase.core.crud.config.CRUDApplication;
77
import com.noubase.core.crud.config.security.StatelessAuthenticationSecurityConfig;
8-
import com.noubase.core.crud.repository.CRUDRepositoryImpl;
9-
import com.noubase.core.crud.repository.CustomMongoRepositoryFactoryBean;
8+
import com.noubase.core.crud.repository.ResourceRepositoryImpl;
9+
import com.noubase.core.crud.repository.ResourceMongoRepositoryFactoryBean;
1010
import com.noubase.core.crud.test.AbstractControllerTest;
1111
import com.noubase.core.security.ExpirableUserDetails;
1212
import com.noubase.core.security.SecurityUserRepository;
@@ -60,8 +60,8 @@ protected SecurityUserRepository userRepo() {
6060
@Configuration
6161
@EnableMongoAuditing
6262
@EnableMongoRepositories(basePackages = "com.noubase.core.crud",
63-
repositoryBaseClass = CRUDRepositoryImpl.class,
64-
repositoryFactoryBeanClass = CustomMongoRepositoryFactoryBean.class)
63+
repositoryBaseClass = ResourceRepositoryImpl.class,
64+
repositoryFactoryBeanClass = ResourceMongoRepositoryFactoryBean.class)
6565
static class MongoConfig extends AbstractMongoConfiguration {
6666

6767
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.noubase.core.crud;
2+
3+
import com.noubase.core.crud.domain.DomainResource;
4+
import org.springframework.data.mongodb.core.mapping.Document;
5+
6+
/**
7+
* Created by rshuper on 04.09.15.
8+
*/
9+
@Document(collection = "core_crud_test_groups")
10+
public class Group extends DomainResource<String> {
11+
12+
private String slug;
13+
14+
public Group() {
15+
}
16+
17+
public Group(String slug) {
18+
this.slug = slug;
19+
}
20+
21+
public String getSlug() {
22+
return slug;
23+
}
24+
25+
public void setSlug(String slug) {
26+
this.slug = slug;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.noubase.core.crud;
2+
3+
import com.noubase.core.crud.contoller.ResourceController;
4+
import com.noubase.core.crud.repository.ResourceRepository;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.http.MediaType;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
/**
11+
* Created by rshuper on 18.08.15.
12+
*/
13+
@RestController
14+
@RequestMapping(value = "/admin/groups", produces = MediaType.APPLICATION_JSON_VALUE)
15+
public class GroupController extends ResourceController<Group, String> {
16+
17+
@Autowired
18+
protected GroupController(ResourceRepository<Group, String> repo) {
19+
super(Group.class, GroupController.class, repo);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.noubase.core.crud;
2+
3+
import com.noubase.core.crud.repository.ResourceRepository;
4+
5+
/**
6+
* Created by rshuper on 18.08.15.
7+
*/
8+
@SuppressWarnings("unused")
9+
public interface GroupRepository extends ResourceRepository<Group, String> {
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.noubase.core.crud;
2+
3+
import com.noubase.core.crud.domain.BindResource;
4+
import org.springframework.data.mongodb.core.index.CompoundIndex;
5+
import org.springframework.data.mongodb.core.index.CompoundIndexes;
6+
import org.springframework.data.mongodb.core.index.Indexed;
7+
import org.springframework.data.mongodb.core.mapping.Document;
8+
9+
/**
10+
* Created by rshuper on 07.09.15.
11+
*/
12+
@Document(collection = "core_crud_test_group_user")
13+
@CompoundIndexes({
14+
@CompoundIndex(name = "pair", unique = true, def = "{'uid': 1, 'gid': 1}")}
15+
)
16+
public class GroupUser extends BindResource<String> {
17+
18+
@Indexed
19+
private String uid;
20+
21+
@Indexed
22+
private String gid;
23+
24+
public GroupUser() {
25+
}
26+
27+
public String getUid() {
28+
return uid;
29+
}
30+
31+
public void setUid(String uid) {
32+
this.uid = uid;
33+
}
34+
35+
public String getGid() {
36+
return gid;
37+
}
38+
39+
public void setGid(String gid) {
40+
this.gid = gid;
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.noubase.core.crud;
2+
3+
import org.springframework.data.mongodb.repository.MongoRepository;
4+
5+
/**
6+
* Created by rshuper on 07.09.15.
7+
*/
8+
@SuppressWarnings("unused")
9+
public interface GroupUserRepository extends MongoRepository<GroupUser, String> {
10+
}

core-crud/src/test/java/com/noubase/core/crud/UserController.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.noubase.core.crud;
22

3-
import com.noubase.core.crud.contoller.CRUDController;
4-
import com.noubase.core.crud.repository.CRUDRepository;
3+
import com.noubase.core.crud.contoller.ResourceController;
4+
import com.noubase.core.crud.repository.ResourceRepository;
55
import org.jetbrains.annotations.NotNull;
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.http.MediaType;
@@ -14,10 +14,10 @@
1414
*/
1515
@RestController
1616
@RequestMapping(value = "/admin/users", produces = MediaType.APPLICATION_JSON_VALUE)
17-
public class UserController extends CRUDController<User, String> {
17+
public class UserController extends ResourceController<User, String> {
1818

1919
@Autowired
20-
protected UserController(CRUDRepository<User, String> repo) {
20+
protected UserController(ResourceRepository<User, String> repo) {
2121
super(User.class, UserController.class, repo);
2222
}
2323

core-crud/src/test/java/com/noubase/core/crud/UserRepository.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.noubase.core.crud;
22

3-
import com.noubase.core.crud.repository.CRUDRepository;
3+
import com.noubase.core.crud.repository.ResourceRepository;
44
import com.noubase.core.security.SecurityUserRepository;
55
import org.jetbrains.annotations.Nullable;
66

77
/**
88
* Created by rshuper on 18.08.15.
99
*/
1010
@SuppressWarnings("unused")
11-
public interface UserRepository extends CRUDRepository<User, String>, SecurityUserRepository<User> {
11+
public interface UserRepository extends ResourceRepository<User, String>, SecurityUserRepository<User> {
1212

1313
@Nullable
1414
User findByUsername(String username);

idema/idema.iml

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:3.2.7.RELEASE" level="project" />
6060
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.1.7.RELEASE" level="project" />
6161
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.0.3" level="project" />
62-
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:1.8.0.RC1" level="project" />
63-
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.1.7.RELEASE" level="project" />
62+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.data:spring-data-mongodb:1.8.0.RELEASE" level="project" />
63+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-tx:4.1.7.RELEASE" level="project" />
6464
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
65-
<orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:jcl-over-slf4j:1.7.12" level="project" />
66-
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.11.0.RC1" level="project" />
65+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.12" level="project" />
66+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.data:spring-data-commons:1.11.0.RELEASE" level="project" />
6767
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.14" level="project" />
6868
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator-annotation-processor:5.2.0.Final" level="project" />
6969
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />

idema/pom.xml

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<artifactId>core-crud</artifactId>
4848
<version>1.0-SNAPSHOT</version>
4949
</dependency>
50+
5051
<dependency>
5152
<groupId>org.springframework.boot</groupId>
5253
<artifactId>spring-boot-starter-web</artifactId>
@@ -90,12 +91,14 @@
9091
<dependency>
9192
<groupId>org.springframework.data</groupId>
9293
<artifactId>spring-data-mongodb</artifactId>
93-
<version>1.8.0.RC1</version>
94+
<version>1.8.0.RELEASE</version>
95+
<scope>provided</scope>
9496
</dependency>
9597
<dependency>
9698
<groupId>org.springframework.data</groupId>
9799
<artifactId>spring-data-commons</artifactId>
98-
<version>1.11.0.RC1</version>
100+
<version>1.11.0.RELEASE</version>
101+
<scope>provided</scope>
99102
</dependency>
100103

101104

idema/src/main/java/com/noubase/idema/config/MongoConfig.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.mongodb.Mongo;
44
import com.mongodb.MongoClient;
55
import com.mongodb.WriteConcern;
6-
import com.noubase.core.crud.repository.CRUDRepositoryImpl;
7-
import com.noubase.core.crud.repository.CustomMongoRepositoryFactoryBean;
6+
import com.noubase.core.crud.repository.ResourceRepositoryImpl;
7+
import com.noubase.core.crud.repository.ResourceMongoRepositoryFactoryBean;
88
import org.jetbrains.annotations.NotNull;
99
import org.springframework.beans.factory.annotation.Value;
1010
import org.springframework.context.annotation.Configuration;
@@ -20,8 +20,8 @@
2020
@Configuration
2121
@EnableMongoAuditing
2222
@EnableMongoRepositories(basePackages = "com.noubase.idema.repository",
23-
repositoryBaseClass = CRUDRepositoryImpl.class,
24-
repositoryFactoryBeanClass = CustomMongoRepositoryFactoryBean.class)
23+
repositoryBaseClass = ResourceRepositoryImpl.class,
24+
repositoryFactoryBeanClass = ResourceMongoRepositoryFactoryBean.class)
2525
public class MongoConfig extends AbstractMongoConfiguration {
2626

2727
@Value("${mongodb.host}")

0 commit comments

Comments
 (0)