Skip to content

Commit

Permalink
Add more monitoring data to solr. EMC-342
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex Lai committed Nov 6, 2024
1 parent cbef2e0 commit 1cd21bc
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ public CatalogueService eidcCatalogue(List<KeywordVocabulary> vocabularies) {
.facetKey("resourceType")
.facetKey("environmentalDomains")
.facetKey("facilityType")
.facetKey("pointOfContact")
.facetKey("operationalStatus")
.documentType(MONITORING_ACTIVITY_TYPE)
.documentType(MONITORING_FACILITY_TYPE)
.documentType(MONITORING_NETWORK_TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class SolrIndex {
private @Field List<String> keywordsParameters;
private @Field List<String> operatingPeriod;
private @Field String objectives;
private @Field List<String> pointOfContact;
private @Field String operationalStatus;
private @Field List<String> responsibleParties;
private @Field List<String> rightsHolder;
private @Field List<String> ror;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public SolrIndex generateIndex(MonitoringActivity document) {
.setKeywordsParameters(grab(document.getKeywordsParameters(), Keyword::getValue))
.setResponsibleParties(grab(document.getResponsibleParties(), ResponsibleParty::getOrganisationName))
.setOperatingPeriod(grab(document.getOperatingPeriod(), MonitoringDocumentUtil::getTimeRange))
.setPointOfContact(grab(document.getResponsibleParties(), ResponsibleParty::getPointOfContact))
.setOperationalStatus(document.getOperationalStatus() == null? "Unknown" : document.getOperationalStatus())
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public SolrIndex generateIndex(MonitoringFacility document) {
.setEnvironmentalDomains(grab(document.getEnvironmentalDomain(), Keyword::getValue))
.setKeywordsParameters(grab(document.getKeywordsParameters(), Keyword::getValue))
.setResponsibleParties(grab(document.getResponsibleParties(), ResponsibleParty::getOrganisationName))
.setOperatingPeriod(grab(document.getOperatingPeriod(), MonitoringDocumentUtil::getTimeRange));
.setOperatingPeriod(grab(document.getOperatingPeriod(), MonitoringDocumentUtil::getTimeRange))
.setPointOfContact(grab(document.getResponsibleParties(), ResponsibleParty::getPointOfContact))
.setOperationalStatus(document.getOperationalStatus() == null? "Unknown" : document.getOperationalStatus())
;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public SolrIndex generateIndex(MonitoringNetwork document) {
.setEnvironmentalDomains(grab(document.getEnvironmentalDomain(), Keyword::getValue))
.setKeywordsParameters(grab(document.getKeywordsParameters(), Keyword::getValue))
.setResponsibleParties(grab(document.getResponsibleParties(), ResponsibleParty::getOrganisationName))
.setPointOfContact(grab(document.getResponsibleParties(), ResponsibleParty::getPointOfContact))
.setOperationalStatus(document.getOperationalStatus() == null? "Unknown" : document.getOperationalStatus())
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public SolrIndex generateIndex(MonitoringProgramme document) {
.setKeywordsParameters(grab(document.getKeywordsParameters(), Keyword::getValue))
.setResponsibleParties(grab(document.getResponsibleParties(), ResponsibleParty::getOrganisationName))
.setOperatingPeriod(grab(document.getOperatingPeriod(), MonitoringDocumentUtil::getTimeRange))
.setPointOfContact(grab(document.getResponsibleParties(), ResponsibleParty::getPointOfContact))
.setOperationalStatus(document.getOperationalStatus() == null? "Unknown" : document.getOperationalStatus())
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public String getRoleDisplayName() {
return toTitlecase(role);
}

public String getPointOfContact() {
return role.equals("pointOfContact")? organisationName : "";
}

private String toTitlecase(String camelCase) {
StringBuilder result = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ public Facet newInstance(@NonNull String key) {
.displayName("Facility type")
.hierarchical(false)
.build();
case "pointOfContact" -> Facet.builder()
.fieldName("pointOfContact")
.displayName("Point of contact")
.hierarchical(false)
.build();
case "operationalStatus" -> Facet.builder()
.fieldName("operationalStatus")
.displayName("Operational status")
.hierarchical(false)
.build();
case "rightsHolder" -> Facet.builder()
.fieldName("rightsHolder")
.displayName("Rights holder")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void checkThatMonitoringActivityDataTransferedToIndex() {
document.setKeywordsParameters(SolrIndexMonitoringGeneratorData.paramList);
document.setResponsibleParties(SolrIndexMonitoringGeneratorData.orgList);
document.setOperatingPeriod(SolrIndexMonitoringGeneratorData.periodList);
document.setOperationalStatus(SolrIndexMonitoringGeneratorData.operationalStatus);

//When
SolrIndex index = generator.generateIndex(document);
Expand All @@ -47,6 +48,8 @@ public void checkThatMonitoringActivityDataTransferedToIndex() {
assertThat(SolrIndexMonitoringGeneratorData.expectedParamList, equalTo(index.getKeywordsParameters()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOrgList, equalTo(index.getResponsibleParties()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPeriodList, equalTo(index.getOperatingPeriod()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPointOfContactList, equalTo(index.getPointOfContact()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOperationalStatus, equalTo(index.getOperationalStatus()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void checkThatMonitoringFacilityDataTransferedToIndex() {
document.setKeywordsParameters(SolrIndexMonitoringGeneratorData.paramList);
document.setResponsibleParties(SolrIndexMonitoringGeneratorData.orgList);
document.setOperatingPeriod(SolrIndexMonitoringGeneratorData.periodList);
document.setOperationalStatus(SolrIndexMonitoringGeneratorData.operationalStatus);

//When
SolrIndex index = generator.generateIndex(document);
Expand All @@ -47,6 +48,8 @@ public void checkThatMonitoringFacilityDataTransferedToIndex() {
assertThat(SolrIndexMonitoringGeneratorData.expectedParamList, equalTo(index.getKeywordsParameters()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOrgList, equalTo(index.getResponsibleParties()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPeriodList, equalTo(index.getOperatingPeriod()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPointOfContactList, equalTo(index.getPointOfContact()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOperationalStatus, equalTo(index.getOperationalStatus()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class SolrIndexMonitoringGeneratorData {
static String objectives = "objective";
static String expectedObjectives = "objective";

static String operationalStatus = "Active";
static String expectedOperationalStatus = "Active";

static Keyword facilityType = Keyword.builder().value("facility_type").build();
static String expectedFacilityType = "facility_type";

Expand All @@ -33,13 +36,16 @@ public class SolrIndexMonitoringGeneratorData {
);

static List<ResponsibleParty> orgList = Arrays.asList(
ResponsibleParty.builder().organisationName("org_1").build(),
ResponsibleParty.builder().organisationName("org_2").build()
ResponsibleParty.builder().organisationName("org_1").role("pointOfContact").build(),
ResponsibleParty.builder().organisationName("org_2").role("funder").build()
);
static List<String> expectedOrgList = Arrays.asList(
"org_1",
"org_2"
);
static List<String> expectedPointOfContactList = Arrays.asList(
"org_1"
);

static List<TimePeriod> periodList = Arrays.asList(
TimePeriod.builder().begin("2024-01-01").end("2024-02-01").build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void checkThatMonitoringNetworkDataTransferedToIndex() {
document.setEnvironmentalDomain(SolrIndexMonitoringGeneratorData.domainList);
document.setKeywordsParameters(SolrIndexMonitoringGeneratorData.paramList);
document.setResponsibleParties(SolrIndexMonitoringGeneratorData.orgList);
document.setOperationalStatus(SolrIndexMonitoringGeneratorData.operationalStatus);

//When
SolrIndex index = generator.generateIndex(document);
Expand All @@ -45,6 +46,8 @@ public void checkThatMonitoringNetworkDataTransferedToIndex() {
assertThat(SolrIndexMonitoringGeneratorData.expectedDomainList, equalTo(index.getEnvironmentalDomains()));
assertThat(SolrIndexMonitoringGeneratorData.expectedParamList, equalTo(index.getKeywordsParameters()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOrgList, equalTo(index.getResponsibleParties()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPointOfContactList, equalTo(index.getPointOfContact()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOperationalStatus, equalTo(index.getOperationalStatus()));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void checkThatMonitoringProgrammeDataTransferedToIndex() {
document.setKeywordsParameters(SolrIndexMonitoringGeneratorData.paramList);
document.setResponsibleParties(SolrIndexMonitoringGeneratorData.orgList);
document.setOperatingPeriod(SolrIndexMonitoringGeneratorData.periodList);
document.setOperationalStatus(SolrIndexMonitoringGeneratorData.operationalStatus);

//When
SolrIndex index = generator.generateIndex(document);
Expand All @@ -47,6 +48,8 @@ public void checkThatMonitoringProgrammeDataTransferedToIndex() {
assertThat(SolrIndexMonitoringGeneratorData.expectedParamList, equalTo(index.getKeywordsParameters()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOrgList, equalTo(index.getResponsibleParties()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPeriodList, equalTo(index.getOperatingPeriod()));
assertThat(SolrIndexMonitoringGeneratorData.expectedPointOfContactList, equalTo(index.getPointOfContact()));
assertThat(SolrIndexMonitoringGeneratorData.expectedOperationalStatus, equalTo(index.getOperationalStatus()));

}
}
2 changes: 2 additions & 0 deletions solr/documents/conf/managed-schema
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
<field name="operatingPeriod" type="pdateranges"/>
<field name="objectives" type="text_general" multiValued="false"/>
<field name="responsibleParties" type="keywords"/>
<field name="pointOfContact" type="keywords"/>
<field name="operationalStatus" type="keywords_lowercase" multiValued="false"/>
<field name="ror" type="rors"/>
<field name="saPhysicalState" type="keywords"/>
<field name="saSpecimenType" type="keywords"/>
Expand Down

0 comments on commit 1cd21bc

Please sign in to comment.