forked from avni-bahmni-integration/integration-service
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#96 - build fix. introduce a new module to keep code common to all in…
…tegrations.
- Loading branch information
1 parent
b5f4f2e
commit 266fdcd
Showing
16 changed files
with
134 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
plugins { | ||
id 'org.springframework.boot' version '2.5.6' | ||
id 'io.spring.dependency-management' version '1.0.10.RELEASE' | ||
id 'java' | ||
} | ||
|
||
group = 'org.avni_integration_service' | ||
version = '0.0.2-SNAPSHOT' | ||
sourceCompatibility = "17" | ||
|
||
bootJar { | ||
enabled = false | ||
} | ||
|
||
jar { | ||
enabled = true | ||
} | ||
|
||
tasks.withType(JavaCompile).all { | ||
options.compilerArgs += ['--enable-preview'] | ||
} | ||
|
||
tasks.withType(Test).all { | ||
jvmArgs += '--enable-preview' | ||
} | ||
|
||
tasks.withType(JavaExec) { | ||
jvmArgs += '--enable-preview' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(':util') | ||
implementation project(':avni') | ||
implementation project(':integration-data') | ||
implementation 'org.springframework.boot:spring-boot-starter' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
implementation "log4j:log4j:1.2.17" | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
targetCompatibility = JavaVersion.VERSION_17 |
45 changes: 45 additions & 0 deletions
45
integration-common/src/main/java/org/avni_integration_service/common/ObservationMapper.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,45 @@ | ||
package org.avni_integration_service.common; | ||
|
||
import org.avni_integration_service.avni.domain.ObservationHolder; | ||
import org.avni_integration_service.integration_data.domain.MappingMetaData; | ||
import org.avni_integration_service.integration_data.domain.framework.MappingException; | ||
import org.avni_integration_service.integration_data.repository.MappingMetaDataRepository; | ||
import org.avni_integration_service.util.ObsDataType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.apache.log4j.Logger; | ||
|
||
import java.util.Map; | ||
|
||
@Component | ||
public class ObservationMapper { | ||
private static final Logger logger = Logger.getLogger(ObservationMapper.class); | ||
private final MappingMetaDataRepository mappingMetaDataRepository; | ||
|
||
@Autowired | ||
public ObservationMapper(MappingMetaDataRepository mappingMetaDataRepository) { | ||
this.mappingMetaDataRepository = mappingMetaDataRepository; | ||
} | ||
|
||
public void mapObservations(ObservationHolder observationHolder, Map<String, Object> externalSystemObservations, String mappingGroupName, String mappingTypeName) { | ||
externalSystemObservations.forEach((key, value) -> { | ||
MappingMetaData mapping = mappingMetaDataRepository.getAvniMappingIfPresent(mappingGroupName, mappingTypeName, key); | ||
if (mapping == null) { | ||
logger.error("Mapping entry not found for observation field: " + key); | ||
return; | ||
} | ||
ObsDataType dataTypeHint = mapping.getDataTypeHint(); | ||
if (dataTypeHint == null) | ||
observationHolder.addObservation(mapping.getAvniValue(), value); | ||
else if (dataTypeHint == ObsDataType.Coded && value != null) { | ||
MappingMetaData answerMapping = mappingMetaDataRepository.getAvniMappingIfPresent(mappingGroupName, mappingTypeName, (String) value); | ||
if (answerMapping == null) { | ||
String errorMessage = "Answer Mapping entry not found for coded concept answer field: " + value; | ||
logger.error(errorMessage); | ||
throw new MappingException(errorMessage); | ||
} | ||
observationHolder.addObservation(mapping.getAvniValue(), answerMapping.getAvniValue()); | ||
} | ||
}); | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
integrator/src/test/java/org/avni_integration_service/AvniIntegrationApplicationTests.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "big-query-integration-poc", | ||
"private_key_id": "dummy_private_key_id", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqPfgaTEWEP3S9w0t\ngsicURfo+nLW09/0KfOPinhYZ4ouzU+3xC4pSlEp8Ut9FgL0AgqNslNaK34Kq+NZ\njO9DAQIDAQABAkAgkuLEHLaqkWhLgNKagSajeobLS3rPT0Agm0f7k55FXVt743hw\nNgkp98bMNrzy9AQ1mJGbQZGrpr4c8ZAx3aRNAiEAoxK/MgGeeLui385KJ7ZOYktj\nhLBNAB69fKwTZFsUNh0CIQEJQRpFCcydunv2bENcN/oBTRw39E8GNv2pIcNxZkcb\nNQIgbYSzn3Py6AasNj6nEtCfB+i1p3F35TK/87DlPSrmAgkCIQDJLhFoj1gbwRbH\n/bDRPrtlRUDDx44wHoEhSDRdy77eiQIgE6z/k6I+ChN1LLttwX0galITxmAYrOBh\nBVl433tgTTQ=\n-----END PRIVATE KEY-----", | ||
"client_email": "dummy email id", | ||
"client_id": "dummy client id", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "dummy auth provider cert url", | ||
"client_x509_cert_url": "dummy cert url" | ||
} |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ include 'amrit' | |
include 'power' | ||
include 'lahi' | ||
include 'glific' | ||
include 'integration-common' |