Skip to content

Commit

Permalink
Merge pull request #33 from devgateway/v0.0.18-pre-release
Browse files Browse the repository at this point in the history
V0.0.18 pre release
  • Loading branch information
jdeanquin-dg authored Apr 11, 2018
2 parents b44b5da + 22cc384 commit 33bdb36
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 48 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This tool allows users to import data in IATI format into a target system. The t
# Requirements
- Java 8 or later
- Apache Maven 3.2.2
- Node 4.7.0 (doesn't work with newest versions of node)

# Configuration
After pulling the source code from github, you need to make some changes to import-core/import-ui/src/main/webapp/client/scripts/conf/index.js.
Expand All @@ -23,6 +24,10 @@ This tool allows users to import data in IATI format into a target system. The t
```
cd import-core/import-ui/src/main/webapp
npm install --dev
##notice that you might need to run. Do it if you get grunt or bower commands not found
npm install grunt -g
npm install bower -g
bower install
grunt build
```

Expand Down
2 changes: 1 addition & 1 deletion import-core/import-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.devgateway.importtool</groupId>
<artifactId>importtool</artifactId>
<version>0.0.17-SNAPSHOT</version>
<version>0.0.18-SNAPSHOT</version>
</parent>
<artifactId>import-rest</artifactId>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion import-core/import-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<parent>
<groupId>org.devgateway.importtool</groupId>
<version>0.0.17-SNAPSHOT</version>
<version>0.0.18-SNAPSHOT</version>
<artifactId>importtool</artifactId>
</parent>
<artifactId>import-services</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,7 @@
import org.apache.commons.logging.LogFactory;
import org.devgateway.importtool.endpoint.EPMessages;
import org.devgateway.importtool.exceptions.CurrencyNotFoundException;
import org.devgateway.importtool.services.processor.helper.ActionResult;
import org.devgateway.importtool.services.processor.helper.ActionStatus;
import org.devgateway.importtool.services.processor.helper.DocumentMapping;
import org.devgateway.importtool.services.processor.helper.Field;
import org.devgateway.importtool.services.processor.helper.FieldMapping;
import org.devgateway.importtool.services.processor.helper.FieldType;
import org.devgateway.importtool.services.processor.helper.FieldValue;
import org.devgateway.importtool.services.processor.helper.FieldValueMapping;
import org.devgateway.importtool.services.processor.helper.IDestinationProcessor;
import org.devgateway.importtool.services.processor.helper.InternalDocument;
import org.devgateway.importtool.services.processor.helper.JsonBean;
import org.devgateway.importtool.services.processor.helper.TokenHeaderInterceptor;
import org.devgateway.importtool.services.processor.helper.ValueMappingException;
import org.devgateway.importtool.services.processor.helper.*;
import org.devgateway.importtool.services.request.ImportRequest;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.HttpClientErrorException;
Expand Down Expand Up @@ -91,6 +79,30 @@ public void setDestinationFieldsList(List<String> destinationFieldsList) {

private ActionStatus actionStatus;

protected static final Map<String, String> tTNameSourceMap = new HashMap<String, String>() {
{
put("AC", Constants.COMMITMENTS);
put("AD", Constants.DISBURSEMENTS);
put("AE", Constants.EXPENDITURES);
put("PC", Constants.COMMITMENTS);
put("PD", Constants.DISBURSEMENTS);
put("PE", Constants.EXPENDITURES);
}
};

protected static final Map<String, String> aTNameDestinationMap = new HashMap<String, String>() {
{
put("AC", Constants.ACTUAL);
put("AD", Constants.ACTUAL);
put("AE", Constants.ACTUAL);
put("PC", Constants.PLANNED);
put("PD", Constants.PLANNED);
put("PE", Constants.PLANNED);


}
};

public ActionStatus getActionStatus() {
return actionStatus;
}
Expand Down Expand Up @@ -654,7 +666,7 @@ private List<JsonBean> getSourceFundings(InternalDocument source, List<FieldMapp

String amount = value.get("value");
String dateString = value.get("date");
fundingDetail.set("transaction_type", getTransactionType(sourceSubType));
fundingDetail.set("transaction_type", getTransactionType(destinationSubType));
fundingDetail.set("adjustment_type", getAdjustmentType(destinationSubType));
fundingDetail.set("transaction_date", getTransactionDate(dateString));
fundingDetail.set("currency", currencyId);
Expand Down Expand Up @@ -929,42 +941,20 @@ private int getTransactionType(String transactionTypeValue) {
}).findFirst().get();

String transactionTypeId = transactionType.getPossibleValues().stream().filter(n -> {
return n.getValue().equals(getTTNameSource(transactionTypeValue));
return n.getValue().equals(tTNameSourceMap.get(transactionTypeValue));
}).findFirst().get().getCode();

return Integer.parseInt(transactionTypeId);

}

private String getTTNameSource(String transactionTypeValue) {
switch (transactionTypeValue) {
case "C":
return "Commitments";
case "D":
return "Disbursements";
}
return "";
}

private String getATNameDestination(String transactionTypeValue) {
switch (transactionTypeValue) {
case "AC":
case "AD":
return "Actual";
case "PC":
case "PD":
return "Planned";
}
return "";
}

private int getAdjustmentType(String value) {
Field adjustmentType = this.getFields().stream().filter(n -> {
return n.getFieldName().equals("adjustment_type");
}).findFirst().get();

String adjustmentTypeValue = adjustmentType.getPossibleValues().stream().filter(n -> {
return n.getValue().equals(getATNameDestination(value));
return n.getValue().equals(aTNameDestinationMap.get(value));
}).findFirst().get().getCode();
return Integer.parseInt(adjustmentTypeValue);
}
Expand Down Expand Up @@ -1269,6 +1259,12 @@ private void instantiateStaticFields() {
actualDisbursements.setDependencies(trnDependencies);
fieldList.add(actualDisbursements);

Field actualExpenditure = new Field(Constants.ACTUAL_EXPENDITURES, "transaction", FieldType.TRANSACTION,
true);
actualExpenditure.setSubType("AE");
actualExpenditure.setDependencies(trnDependencies);
fieldList.add(actualExpenditure);

Field plannedCommitments = new Field("Planned Commitments", "transaction", FieldType.TRANSACTION, true);
plannedCommitments.setSubType("PC");
plannedCommitments.setDependencies(trnDependencies);
Expand All @@ -1279,6 +1275,11 @@ private void instantiateStaticFields() {
plannedDisbursements.setDependencies(trnDependencies);
fieldList.add(plannedDisbursements);

Field plannedExpenditures = new Field(Constants.PLANNED_EXPENDITURES, "transaction", FieldType.TRANSACTION, true);
plannedExpenditures.setSubType("PE");
plannedExpenditures.setDependencies(trnDependencies);
fieldList.add(plannedExpenditures);

// Currency
Field currency = new Field("Currency Code", "currency_code", FieldType.LIST, true);
currency.setPossibleValues(getCodeListValues("fundings~funding_details~currency"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.devgateway.importtool.model.Language;
import org.devgateway.importtool.services.processor.helper.ActionStatus;
import org.devgateway.importtool.services.processor.helper.Field;
import org.devgateway.importtool.services.processor.helper.FieldType;
import org.devgateway.importtool.services.processor.helper.FieldValue;
import org.devgateway.importtool.services.processor.helper.ISourceProcessor;
import org.devgateway.importtool.services.processor.helper.InternalDocument;
import org.devgateway.importtool.services.processor.helper.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
Expand Down Expand Up @@ -885,6 +880,12 @@ protected void instantiateStaticFields() {
disbursements.setSubTypeCode("3");
fieldList.add(disbursements);

Field expenditure = new Field(Constants.EXPENDITURES, "transaction", FieldType.TRANSACTION, true);
expenditure.setSubType("E");
expenditure.setSubTypeCode("4");
fieldList.add(expenditure);


// Organization Fields
Field participatingOrg = new Field("Funding Organization", "participating-org", FieldType.ORGANIZATION, true);
participatingOrg.setSubType("Funding");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ public class Constants {
public static final String ENABLED_TAG = "enabled";
public static final String IMPORT_STATUS_MESSAGE = "Importing %s of %s projects";

public static final String ACTUAL = "Actual";
public static final String PLANNED = "Planned";
public static final String COMMITMENTS = "Commitments";
public static final String DISBURSEMENTS = "Disbursements";
public static final String EXPENDITURES = "Expenditures";

public static final String ACTUAL_EXPENDITURES = ACTUAL + " " + EXPENDITURES;
public static final String PLANNED_EXPENDITURES = PLANNED + " " + EXPENDITURES;


}
2 changes: 1 addition & 1 deletion import-core/import-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.devgateway.importtool</groupId>
<artifactId>importtool</artifactId>
<version>0.0.17-SNAPSHOT</version>
<version>0.0.18-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion import-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>importtool</artifactId>
<name>IMPORT TOOL Parent Package</name>
<url>http://maven.apache.org</url>
<version>0.0.17-SNAPSHOT</version>
<version>0.0.18-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<version>1.2.2.RELEASE</version>
Expand Down

0 comments on commit 33bdb36

Please sign in to comment.