Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aomegax committed Aug 21, 2023
1 parent 729b59e commit 10479af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/it/gov/pagopa/nodoretotablestorage/Info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.nodoretodatastore;
package it.gov.pagopa.nodoretotablestorage;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class NodoReEventToDataStore {
*/

private Pattern replaceDashPattern = Pattern.compile("-([a-zA-Z])");
private static String NA = "NA";
private static String na = "NA";
private static String uniqueIdField = "uniqueId";
private static String insertedDateField = "insertedDate";
private static String insertedTimestampField = "insertedTimestamp";
Expand All @@ -58,13 +58,13 @@ private static TableServiceClient getTableServiceClient(){

private void addToBatch(Logger logger, Map<String,List<TableTransactionAction>> partitionEvents, Map<String, Object> reEvent) {
if(reEvent.get(uniqueIdField) == null) {
logger.warning("event has no '" + uniqueIdField + "' field");
logger.warning(String.format("event has no '%s' field", uniqueIdField));
}
else {
TableEntity entity = new TableEntity((String) reEvent.get(partitionKeyField), (String)reEvent.get(uniqueIdField));
entity.setProperties(reEvent);
if(!partitionEvents.containsKey(entity.getPartitionKey())){
partitionEvents.put(entity.getPartitionKey(),new ArrayList<TableTransactionAction>());
partitionEvents.put(entity.getPartitionKey(),new ArrayList<>());
}
partitionEvents.get(entity.getPartitionKey()).add(new TableTransactionAction(TableTransactionActionType.UPSERT_REPLACE,entity));
}
Expand Down Expand Up @@ -133,12 +133,12 @@ public void processNodoReEvent (
reEvent.put(s, v);
});

String insertedDateValue = reEvent.get(insertedTimestampField) != null ? ((String)reEvent.get(insertedTimestampField)).substring(0, 10) : NA;
String insertedDateValue = reEvent.get(insertedTimestampField) != null ? ((String)reEvent.get(insertedTimestampField)).substring(0, 10) : na;
reEvent.put(insertedDateField, insertedDateValue);

zipPayload(logger, reEvent);

String idDominio = reEvent.get(idDominioField) != null ? reEvent.get(idDominioField).toString() : NA;
String idDominio = reEvent.get(idDominioField) != null ? reEvent.get(idDominioField).toString() : na;

addToBatch(logger, partitionEvents, getEvent(insertedDateValue, reEvent));
addToBatch(logger, partitionEvents, getEvent(insertedDateValue + "-" + idDominio, reEvent));
Expand Down

0 comments on commit 10479af

Please sign in to comment.