Skip to content

Commit

Permalink
MODEXPW-368 - Align csv-file format with bulk-operations (folio-org#413)
Browse files Browse the repository at this point in the history
* MODEXPW-368 - reverting addresses transformation

* MODEXPW-368 - reverting addresses transformation
  • Loading branch information
khandramai authored Feb 23, 2023
1 parent d75014c commit c2ac1df
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.folio.dew.utils.BulkEditProcessorHelper.dateToString;
import static org.folio.dew.utils.BulkEditProcessorHelper.ofEmptyString;
import static org.folio.dew.utils.Constants.ARRAY_DELIMITER;
import static org.folio.dew.utils.Constants.ITEM_DELIMITER;
import static org.folio.dew.utils.Constants.KEY_VALUE_DELIMITER;
Expand Down Expand Up @@ -111,17 +110,17 @@ private String addressesToString(List<Address> addresses, ErrorServiceArgs args)
}

private String addressToString(Address address, ErrorServiceArgs args) {
List<String> data = new ArrayList<>();
ofEmptyString(address.getId()).ifPresent(data::add);
ofEmptyString(address.getCountryId()).ifPresent(data::add);
ofEmptyString(address.getAddressLine1()).ifPresent(data::add);
ofEmptyString(address.getAddressLine2()).ifPresent(data::add);
ofEmptyString(address.getCity()).ifPresent(data::add);
ofEmptyString(address.getRegion()).ifPresent(data::add);
ofEmptyString(address.getPostalCode()).ifPresent(data::add);
ofNullable(address.getPrimaryAddress()).ifPresent(primary -> data.add(primary.toString()));
ofEmptyString(userReferenceService.getAddressTypeDescById(address.getAddressTypeId(), args)).ifPresent(data::add);
return String.join(ARRAY_DELIMITER, escaper.escape(data));
List<String> addressData = new ArrayList<>();
addressData.add(ofNullable(address.getId()).orElse(EMPTY));
addressData.add(ofNullable(address.getCountryId()).orElse(EMPTY));
addressData.add(ofNullable(address.getAddressLine1()).orElse(EMPTY));
addressData.add(ofNullable(address.getAddressLine2()).orElse(EMPTY));
addressData.add(ofNullable(address.getCity()).orElse(EMPTY));
addressData.add(ofNullable(address.getRegion()).orElse(EMPTY));
addressData.add(ofNullable(address.getPostalCode()).orElse(EMPTY));
addressData.add(nonNull(address.getPrimaryAddress()) ? address.getPrimaryAddress().toString() : EMPTY);
addressData.add(userReferenceService.getAddressTypeDescById(address.getAddressTypeId(), args));
return String.join(ARRAY_DELIMITER, escaper.escape(addressData));
}

private String customFieldsToString(Map<String, Object> map) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
User name,User id,External system id,Barcode,Active,Type,Patron group,Departments,Proxy for,Last name,First name,Middle name,Preferred first name,Email,Phone,Mobile phone,Date of birth,Addresses,Preferred contact type id,Enrollment date,Expiration date,Created date,Updated date,Tags,Custom fields
morty,bec20636-fb68-41fd-84ea-2cf910673599,,456,true,,staff,,,morty,panic,,,[email protected],,,,BE;Address line 1;Address line 2;Some City;12345;Home Address,002,2020-10-07 04:00:00.000Z,,2021-12-03 14:25:55.129Z,2021-12-03 14:25:55.129Z,tag1;tag2;tag3,TestTextArea:morty's text area|TestRadio:r2|TestTextField:morty's text field|TestSingleSelect:ss2|TestMultiSelect:ms2;ms1|TestCheckbox:true
morty,bec20636-fb68-41fd-84ea-2cf910673599,,456,true,,staff,,,morty,panic,,,[email protected],,,,;BE;Address line 1;Address line 2;Some City;;12345;;Home Address,002,2020-10-07 04:00:00.000Z,,2021-12-03 14:25:55.129Z,2021-12-03 14:25:55.129Z,tag1;tag2;tag3,TestTextArea:morty's text area|TestRadio:r2|TestTextField:morty's text field|TestSingleSelect:ss2|TestMultiSelect:ms2;ms1|TestCheckbox:true
rick,2205005b-ca51-4a04-87fd-938eefa8f6de,,123,true,,staff,,,rick,psych,,,[email protected],,,,,002,2020-10-07 04:00:00.000Z,,2021-12-05 03:23:39.674Z,2021-12-05 03:23:39.674Z,,TestMultiSelect:
sheldon,b4cee18d-f862-4ef1-95a5-879fdd619603,,789,true,,staff,,,sheldon,bazinga,,,[email protected],,,,,002,,,2021-12-05 03:23:37.989Z,2021-12-05 03:23:37.989Z,,
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
User name,User id,External system id,Barcode,Active,Type,Patron group,Departments,Proxy for,Last name,First name,Middle name,Preferred first name,Email,Phone,Mobile phone,Date of birth,Addresses,Preferred contact type id,Enrollment date,Expiration date,Created date,Updated date,Tags,Custom fields
morty,bec20636-fb68-41fd-84ea-2cf910673599,,456,true,,staff,,,morty,panic,,,[email protected],,,,BE;Address line 1;Address line 2;Some City;12345;Home Address,002,2020-10-07 04:00:00.000Z,,2021-12-03 14:25:55.129Z,2021-12-03 14:25:55.129Z,tag1;tag2;tag3,TestTextArea:morty's text area|TestRadio:r2|TestTextField:morty's text field|TestSingleSelect:ss2|TestMultiSelect:ms2;ms1|TestCheckbox:true
morty,bec20636-fb68-41fd-84ea-2cf910673599,,456,true,,staff,,,morty,panic,,,[email protected],,,,;BE;Address line 1;Address line 2;Some City;;12345;;Home Address,002,2020-10-07 04:00:00.000Z,,2021-12-03 14:25:55.129Z,2021-12-03 14:25:55.129Z,tag1;tag2;tag3,TestTextArea:morty's text area|TestRadio:r2|TestTextField:morty's text field|TestSingleSelect:ss2|TestMultiSelect:ms2;ms1|TestCheckbox:true
sheldon,b4cee18d-f862-4ef1-95a5-879fdd619603,,789,true,,staff,,,sheldon,bazinga,,,[email protected],,,,,002,,,2021-12-05 03:23:37.989Z,2021-12-05 03:23:37.989Z,,
6 changes: 3 additions & 3 deletions src/test/resources/output/bulk_edit_users_empty_reference.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
User name,User id,External system id,Barcode,Active,Type,Patron group,Departments,Proxy for,Last name,First name,Middle name,Preferred first name,Email,Phone,Mobile phone,Date of birth,Addresses,Preferred contact type id,Enrollment date,Expiration date,Created date,Updated date,Tags,Custom fields
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyAddressType,true,,staff,,,morty,panic,,,[email protected],,,,add1;add2;city,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyPreferredContactTypeId,true,,staff,,,morty,panic,,,[email protected],,,,add1;add2;city;Home Address,,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyDepartments,true,,staff,,,morty,panic,,,[email protected],,,,add1;add2;city;Home Address,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyAddressType,true,,staff,,,morty,panic,,,[email protected],,,,;;add1;add2;city;;;;,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyPreferredContactTypeId,true,,staff,,,morty,panic,,,[email protected],,,,;;add1;add2;city;;;;Home Address,,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,emptyDepartments,true,,staff,,,morty,panic,,,[email protected],,,,;;add1;add2;city;;;;Home Address,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
User name,User id,External system id,Barcode,Active,Type,Patron group,Departments,Proxy for,Last name,First name,Middle name,Preferred first name,Email,Phone,Mobile phone,Date of birth,Addresses,Preferred contact type id,Enrollment date,Expiration date,Created date,Updated date,Tags,Custom fields
morty,bec20636-fb68-41fd-84ea-2cf910673599,,badAddressType,true,,staff,,,morty,panic,,,[email protected],,,,add1;add2;city;db541cda-fcc7-403b-8077-3613f3244901,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,badDepartments,true,,staff,103aee0f-c5f6-44de-94aa-74093f0e45d9,,morty,panic,,,[email protected],,,,add1;add2;city;Home Address,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,badAddressType,true,,staff,,,morty,panic,,,[email protected],,,,;;add1;add2;city;;;;db541cda-fcc7-403b-8077-3613f3244901,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,
morty,bec20636-fb68-41fd-84ea-2cf910673599,,badDepartments,true,,staff,103aee0f-c5f6-44de-94aa-74093f0e45d9,,morty,panic,,,[email protected],,,,;;add1;add2;city;;;;Home Address,002,2020-10-07 04:00:00.000Z,,2022-03-31 09:05:38.808Z,2022-03-31 09:05:38.808Z,,

0 comments on commit c2ac1df

Please sign in to comment.