Skip to content

Commit

Permalink
Add new cosntructor in MongoDBSubmodelRepositoryFactory which uses th…
Browse files Browse the repository at this point in the history
…e default repository name

Signed-off-by: Zai Müller-Zhang <[email protected]>
  • Loading branch information
zhangzai123 committed Sep 28, 2023
1 parent d8dac1d commit 37e2e75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,44 +49,45 @@ public class MongoDBSubmodelRepositoryFactory implements SubmodelRepositoryFacto
private String collectionName;
private SubmodelServiceFactory submodelServiceFactory;
private Collection<Submodel> submodels;

private String smRepositoryName;
private GridFsTemplate gridFsTemplate;

@Autowired(required = false)
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate,
@Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName,
SubmodelServiceFactory submodelServiceFactory) {
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory) {
this.mongoTemplate = mongoTemplate;
this.collectionName = collectionName;
this.submodelServiceFactory = submodelServiceFactory;
}

public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate,
@Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName,
SubmodelServiceFactory submodelServiceFactory, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName, GridFsTemplate gridFsTemplate) {

public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory,
@Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName, GridFsTemplate gridFsTemplate) {
this(mongoTemplate, collectionName, submodelServiceFactory);
this.smRepositoryName = smRepositoryName;
this.gridFsTemplate = gridFsTemplate;
}

public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory,
GridFsTemplate gridFsTemplate) {
this(mongoTemplate, collectionName, submodelServiceFactory);
this.gridFsTemplate = gridFsTemplate;
}

@Autowired(required = false)
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate,
@Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName,
SubmodelServiceFactory submodelServiceFactory, Collection<Submodel> submodels) {
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory,
Collection<Submodel> submodels) {
this(mongoTemplate, collectionName, submodelServiceFactory);
this.submodels = submodels;
}

@Autowired(required = false)
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate,
@Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName,
SubmodelServiceFactory submodelServiceFactory, Collection<Submodel> submodels, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName, GridFsTemplate gridFsTemplate) {
public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory,
Collection<Submodel> submodels, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName, GridFsTemplate gridFsTemplate) {
this(mongoTemplate, collectionName, submodelServiceFactory, submodels);
this.smRepositoryName = smRepositoryName;
this.gridFsTemplate = gridFsTemplate;
}

@Override
public SubmodelRepository create() {
if (this.submodels == null || this.submodels.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class TestMongoDBSubmodelRepository extends SubmodelRepositorySuite {
protected SubmodelRepository getSubmodelRepository() {
MongoDBUtilities.clearCollection(TEMPLATE, COLLECTION);

return new MongoDBSubmodelRepositoryFactory(TEMPLATE, COLLECTION, SUBMODEL_SERVICE_FACTORY, CONFIGURED_SM_REPO_NAME, GRIDFS_TEMPLATE).create();
return new MongoDBSubmodelRepositoryFactory(TEMPLATE, COLLECTION, SUBMODEL_SERVICE_FACTORY, GRIDFS_TEMPLATE).create();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public void deleteNestedSubmodelElementInSubmodelElementList() {
public void getDefaultSubmodelRepositoryName() {
SubmodelRepository repo = getSubmodelRepository();

assertEquals("configured-sm-repo-name", repo.getName());
assertEquals("sm-repo", repo.getName());
}

@Test
Expand Down

0 comments on commit 37e2e75

Please sign in to comment.