Skip to content

Commit

Permalink
Added property to parametrize the application instance
Browse files Browse the repository at this point in the history
  • Loading branch information
jorizci committed Aug 30, 2018
1 parent 74cef2b commit 66cc9ef
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class AnalysisServiceConfiguration {

private final String CATEGORY_ID = "analysis";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Analysis, String, String> prefixAnalysisAccessionServ
@Bean
public AccessioningService<Analysis, String, Long> analysisAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
analysisAccessioningDatabaseService(),
analysis -> analysis.getSubmissionAccount() + "_" + analysis.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class ArrayServiceConfiguration {

private final String CATEGORY_ID = "array";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Array, String, String> prefixArrayAccessionService()
@Bean
public AccessioningService<Array, String, Long> arrayAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
arrayAccessioningDatabaseService(),
array -> array.getSubmissionAccount() + "_" + array.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class DacServiceConfiguration {

private final String CATEGORY_ID = "dac";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Dac, String, String> prefixDacAccessionService() {
@Bean
public AccessioningService<Dac, String, Long> dacAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
dacAccessioningDatabaseService(),
dac -> dac.getSubmissionAccount() + "_" + dac.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class DatasetServiceConfiguration {

private final String CATEGORY_ID = "dataset";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Dataset, String, String> prefixDatasetAccessionServic
@Bean
public AccessioningService<Dataset, String, Long> datasetAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
datasetAccessioningDatabaseService(),
dataset -> dataset.getSubmissionAccount() + "_" + dataset.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class ExperimentServiceConfiguration {

private final String CATEGORY_ID = "experiment";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Experiment, String, String> prefixExperimentAccession
@Bean
public AccessioningService<Experiment, String, Long> experimentAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
experimentAccessioningDatabaseService(),
experiment -> experiment.getSubmissionAccount() + "_" + experiment.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -55,6 +56,9 @@ public class FileServiceConfiguration {

private final String CATEGORY_ID = "file";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -76,7 +80,7 @@ public AccessioningService<FileModel, String, String> prefixFileAccessionService
@Bean
public AccessioningService<FileModel, String, Long> fileAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService, monotonicDatabaseService()),
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService, monotonicDatabaseService()),
fileAccessioningDatabaseService(),
fileModel -> fileModel.getHash(),
message -> message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class PolicyServiceConfiguration {

private final String CATEGORY_ID = "policy";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Policy, String, String> prefixPolicyAccessionService(
@Bean
public AccessioningService<Policy, String, Long> policyAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
policyAccessioningDatabaseService(),
policy -> policy.getSubmissionAccount() + "_" + policy.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@
@EnableBasicRestControllerAdvice
public class RestConfiguration {



}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class RunServiceConfiguration {

private final String CATEGORY_ID = "run";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Run, String, String> prefixRunAccessionService() {
@Bean
public AccessioningService<Run, String, Long> runAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
runAccessioningDatabaseService(),
run -> run.getSubmissionAccount() + "_" + run.getAlias(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -65,6 +66,9 @@ public class SampleControlledServiceConfiguration {

private final String CATEGORY_ID = "sample";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand Down Expand Up @@ -95,7 +99,8 @@ public AccessioningService<SampleControlled, String, String> prefixSampleControl
@Bean
public AccessioningService<SampleControlled, String, Long> sampleControlledAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01-sample-open", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId + "-controlled-sample",
blockService,
monotonicDatabaseService()),
sampleControlledAccessioningDatabaseService(),
sampleControlled -> sampleControlled.getSubmissionAccount() + "_" + sampleControlled.getAlias(),
Expand Down Expand Up @@ -137,7 +142,7 @@ public AccessioningService<SampleOpen, String, String> prefixSampleOpenAccession
@Bean
public AccessioningService<SampleOpen, String, Long> sampleOpenAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01-sample-open", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId + "-open-sample", blockService,
monotonicDatabaseService()),
sampleOpenAccessioningDatabaseService(),
sampleOpen -> sampleOpen.getBiosampleAccession(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package uk.ac.ebi.ega.accession.configuration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class StudyServiceConfiguration {

private final String CATEGORY_ID = "study";

@Value("${accessioning.instanceId}")
private String applicationInstanceId;

@Autowired
private ContiguousIdBlockService blockService;

Expand All @@ -77,7 +81,7 @@ public AccessioningService<Study, String, String> prefixStudyAccessionService()
@Bean
public AccessioningService<Study, String, Long> studyAccessionService() {
return new BasicAccessioningService<>(
new MonotonicAccessionGenerator<>(CATEGORY_ID, "ega-accession-01", blockService,
new MonotonicAccessionGenerator<>(CATEGORY_ID, applicationInstanceId, blockService,
monotonicDatabaseService()),
studyAccessioningDatabaseService(),
study -> study.getSubmissionAccount() + "_" + study.getAlias(),
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ endpoints.health.sensitive=false
# APPLICATION
#####################################################################################

accessioning.namespace=EGA
accessioning.variant.instanceId=@instance.id@;
accessioning.instanceId=@instance.id@

accessioning.monotonic.file.blockSize=1000
accessioning.monotonic.file.blockStartValue=0
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# limitations under the License.
#
#
accessioning.namespace=EGA
accessioning.variant.instanceId=instance-01;
accessioning.instanceId=instance-01;

accessioning.monotonic.file.blockSize=1000
accessioning.monotonic.file.blockStartValue=0
Expand Down

0 comments on commit 66cc9ef

Please sign in to comment.