-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from protegeproject/update_projectId_in_revisi…
…onsEvent Update project id in revisions event
- Loading branch information
Showing
15 changed files
with
113 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 39 additions & 1 deletion
40
src/main/java/edu/stanford/protege/webprotegeeventshistory/config/MongoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,48 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.config; | ||
|
||
import com.mongodb.*; | ||
import edu.stanford.protege.webprotegeeventshistory.config.converters.*; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; | ||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions; | ||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Arrays; | ||
|
||
|
||
@Configuration | ||
@EnableMongoRepositories(basePackages = "edu.stanford.protege.webprotegeeventshistory") | ||
public class MongoConfiguration { | ||
public class MongoConfiguration extends AbstractMongoClientConfiguration { | ||
|
||
@Value("${spring.data.mongodb.database}") | ||
private String databaseName; | ||
|
||
@Value("${spring.data.mongodb.uri}") | ||
private String mongoUri; | ||
|
||
@Nonnull | ||
@Override | ||
protected String getDatabaseName() { | ||
return databaseName; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public MongoClientSettings mongoClientSettings() { | ||
return MongoClientSettings.builder() | ||
.applyConnectionString(new ConnectionString(mongoUri)) | ||
.build(); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public MongoCustomConversions customConversions() { | ||
return new MongoCustomConversions(Arrays.asList( | ||
new ProjectIdToStringConverter(), | ||
new StringToProjectIdConverter() | ||
)); | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
...tanford/protege/webprotegeeventshistory/config/converters/ProjectIdToStringConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.config.converters; | ||
|
||
import edu.stanford.protege.webprotege.common.ProjectId; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.convert.WritingConverter; | ||
|
||
@WritingConverter | ||
public class ProjectIdToStringConverter implements Converter<ProjectId, String> { | ||
@Override | ||
public String convert(ProjectId projectId) { | ||
return projectId.id(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...tanford/protege/webprotegeeventshistory/config/converters/StringToProjectIdConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.config.converters; | ||
|
||
import edu.stanford.protege.webprotege.common.ProjectId; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.convert.ReadingConverter; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
@ReadingConverter | ||
public class StringToProjectIdConverter implements Converter<String, ProjectId> { | ||
@Override | ||
public ProjectId convert(@Nonnull String source) { | ||
return ProjectId.valueOf(source); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters