Skip to content

Commit d8496cb

Browse files
committed
Load Cached Organisation Repo as Bean
1 parent 440f69e commit d8496cb

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

Diff for: project-management-infrastructure/src/main/java/life/qbic/projectmanagement/infrastructure/CachedOrganisationRepository.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import life.qbic.logging.api.Logger;
2121
import life.qbic.projectmanagement.application.OrganisationRepository;
2222
import life.qbic.projectmanagement.domain.Organisation;
23+
import org.springframework.beans.factory.annotation.Autowired;
2324
import org.springframework.stereotype.Component;
2425

2526
/**
@@ -35,7 +36,6 @@
3536
*
3637
* @since 1.0.0s
3738
*/
38-
@Component
3939
public class CachedOrganisationRepository implements OrganisationRepository {
4040

4141
private static final Logger log = logger(CachedOrganisationRepository.class);
@@ -53,7 +53,6 @@ public CachedOrganisationRepository(int cacheSize) {
5353
this.configuredCacheSize = cacheSize;
5454
}
5555

56-
5756
public CachedOrganisationRepository() {
5857
this.configuredCacheSize = DEFAULT_CACHE_SIZE;
5958
}

Diff for: user-interface/src/main/java/life/qbic/datamanager/AppConfig.java

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import life.qbic.infrastructure.email.identity.IdentityEmailServiceProvider;
2727
import life.qbic.infrastructure.email.project.ProjectManagementEmailServiceProvider;
2828
import life.qbic.projectmanagement.application.AppContextProvider;
29+
import life.qbic.projectmanagement.application.OrganisationRepository;
2930
import life.qbic.projectmanagement.application.ProjectInformationService;
3031
import life.qbic.projectmanagement.application.api.SampleCodeService;
3132
import life.qbic.projectmanagement.application.authorization.acl.ProjectAccessService;
@@ -67,6 +68,7 @@
6768
import life.qbic.projectmanagement.application.sample.SampleInformationService;
6869
import life.qbic.projectmanagement.application.sample.qualitycontrol.QualityControlService;
6970
import life.qbic.projectmanagement.domain.repository.ProjectRepository;
71+
import life.qbic.projectmanagement.infrastructure.CachedOrganisationRepository;
7072
import org.jobrunr.scheduling.JobScheduler;
7173
import org.springframework.beans.factory.annotation.Value;
7274
import org.springframework.context.annotation.Bean;
@@ -97,6 +99,11 @@ public IdentityService userRegistrationService(
9799
return new IdentityService(userRepository);
98100
}
99101

102+
@Bean
103+
public OrganisationRepository organisationRepository() {
104+
return new CachedOrganisationRepository();
105+
}
106+
100107

101108
@Bean
102109
public NewPasswordInput newPasswordInput(IdentityService identityService) {

Diff for: user-interface/src/main/java/life/qbic/datamanager/views/projects/project/experiments/experiment/ExperimentDetailsComponent.java

+17-15
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class ExperimentDetailsComponent extends PageArea {
100100
private final Disclaimer noExperimentalVariablesDefined;
101101
private final Disclaimer noExperimentalGroupsDefined;
102102
private final Disclaimer addExperimentalVariablesNote;
103-
private final DeletionService deletionService;
103+
private final transient DeletionService deletionService;
104104
private final transient TerminologyService terminologyService;
105105
private final transient MessageSourceNotificationFactory messageSourceNotificationFactory;
106106
private final transient CancelConfirmationDialogFactory cancelConfirmationDialogFactory;
@@ -211,7 +211,8 @@ private void onEditButtonClicked() {
211211
"Experiment information could not be retrieved from service");
212212
}
213213

214-
Map<SampleOriginType, Set<OntologyTerm>> usedTerms = getOntologyTermsUsedInSamples(experimentId);
214+
Map<SampleOriginType, Set<OntologyTerm>> usedTerms = getOntologyTermsUsedInSamples(
215+
experimentId);
215216

216217
optionalExperiment.ifPresent(experiment -> {
217218
EditExperimentDialog editExperimentDialog = new EditExperimentDialog(
@@ -246,7 +247,8 @@ private void showCancelConfirmationDialog(EditExperimentDialog editExperimentDia
246247
.open();
247248
}
248249

249-
private Map<SampleOriginType, Set<OntologyTerm>> getOntologyTermsUsedInSamples(ExperimentId experimentId) {
250+
private Map<SampleOriginType, Set<OntologyTerm>> getOntologyTermsUsedInSamples(
251+
ExperimentId experimentId) {
250252
Map<SampleOriginType, Set<OntologyTerm>> result = new EnumMap<>(SampleOriginType.class);
251253
Collection<Sample> samples = sampleInformationService.retrieveSamplesForExperiment(experimentId)
252254
.valueOrElse(new ArrayList<>());
@@ -725,6 +727,11 @@ public static BioIcon getDefaultBioIcon(SampleSourceType sampleSourceType) {
725727
};
726728
}
727729

730+
public static List<BioIcon> getOptionsForType(SampleSourceType type) {
731+
return Arrays.stream(BioIcon.values()).filter(o ->
732+
o.getType().equals(type)).toList();
733+
}
734+
728735
public String getLabel() {
729736
return label;
730737
}
@@ -737,17 +744,19 @@ public IconResource getIconResource() {
737744
return iconResource;
738745
}
739746

740-
public static List<BioIcon> getOptionsForType(SampleSourceType type) {
741-
return Arrays.stream(BioIcon.values()).filter(o ->
742-
o.getType().equals(type)).toList();
743-
}
744-
745747
private static class Constants {
746748

747749
public static final String DEFAULT_LABEL = "default";
748750
}
749751
}
750752

753+
/**
754+
* Describes the source level of a sample: species, specimen or analyte
755+
*/
756+
public enum SampleSourceType {
757+
SPECIES, SPECIMEN, ANALYTE
758+
}
759+
751760
/**
752761
* Wrapper class for different icon resources, e.g. VaadinIcons or custom SVGs. Provides a method
753762
* to create the respective Icon component.
@@ -773,11 +782,4 @@ public AbstractIcon createIcon() {
773782
}
774783
}
775784
}
776-
777-
/**
778-
* Describes the source level of a sample: species, specimen or analyte
779-
*/
780-
public enum SampleSourceType {
781-
SPECIES, SPECIMEN, ANALYTE
782-
}
783785
}

0 commit comments

Comments
 (0)