Skip to content

Commit

Permalink
Merge branch 'SRU2023' into SRU2023_v10
Browse files Browse the repository at this point in the history
  • Loading branch information
zubri authored Nov 17, 2023
2 parents d3c2aa6 + 2df8916 commit e96050d
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 57 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,5 @@ release.sh
.idea/runConfigurations.xml
.idea/.name
*.pb
.idea/sonarlint/issuestore/
.idea/sonarlint/issuestore/
.idea/sonarlint/issuestore/
.java-version
.idea/sonarlint/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Prowide Core - CHANGELOG

#### 10.1.12 - November 2023
* (PW-1697) Fixed validation/parse pattern in field 29O
* (PW-1697) MT306 changes in field 30I
* Added DistinguishedName with Builder in order to encapsulate the BIC branch name logic

#### 10.1.11 - November 2023
* (PW-1697) Fixed validation pattern in fields 14[H,K,L,M,N,O] and 29J

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* <p>Structure definition
* <ul>
* <li>validation pattern: <code>4!c/&lt;HHMM&gt;&lt;HHMM&gt;</code></li>
* <li>parser pattern: <code>S/S</code></li>
* <li>parser pattern: <code>S/&lt;HHMM&gt;&lt;HHMM&gt;</code></li>
* <li>components pattern: <code>SHH</code></li>
* </ul>
*
Expand Down Expand Up @@ -85,7 +85,7 @@ public class Field29O extends Field implements Serializable {
*/
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public static final String PARSER_PATTERN = "S/S";
public static final String PARSER_PATTERN = "S/<HHMM><HHMM>";

/**
* @deprecated Use {@link #typesPattern()} method instead.
Expand Down Expand Up @@ -193,8 +193,19 @@ public static Tag emptyTag() {
@Override
public void parse(final String value) {
init(3);
setComponent1(SwiftParseUtils.getTokenFirst(value, "/"));
setComponent2(SwiftParseUtils.getTokenSecondLast(value, "/"));
if (value != null) {
setComponent1(SwiftParseUtils.getTokenFirst(value, "/"));
String toparse = SwiftParseUtils.getTokenSecondLast(value, "/");
if (toparse != null) {
if (toparse.length() >= 1) {
int endIndex = Math.min(4, toparse.length());
setComponent2(StringUtils.substring(toparse, 0, endIndex));
}
if (toparse.length() > 4) {
setComponent3(StringUtils.substring(toparse, 4));
}
}
}
}

/**
Expand All @@ -206,6 +217,7 @@ public String getValue() {
append(result, 1);
result.append("/");
append(result, 2);
append(result, 3);
return result.toString();
}

Expand Down Expand Up @@ -273,7 +285,7 @@ public String typesPattern() {
*/
@Override
public String parserPattern() {
return "S/S";
return "S/<HHMM><HHMM>";
}

/**
Expand Down
126 changes: 83 additions & 43 deletions src/generated/java/com/prowidesoftware/swift/model/field/Field30I.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,19 @@
*/
package com.prowidesoftware.swift.model.field;

import com.prowidesoftware.swift.model.Tag;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.prowidesoftware.Generated;
import com.prowidesoftware.deprecation.ProwideDeprecated;
import com.prowidesoftware.deprecation.TargetYear;

import java.io.Serializable;
import java.util.Locale;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

import java.util.Calendar;

import com.prowidesoftware.swift.model.field.DateContainer;
import com.prowidesoftware.swift.model.field.DateResolver;

import org.apache.commons.lang3.StringUtils;

import com.prowidesoftware.swift.model.field.SwiftParseUtils;
import com.prowidesoftware.swift.model.field.Field;
import com.prowidesoftware.swift.model.*;
import com.prowidesoftware.swift.model.SwiftMessage;
import com.prowidesoftware.swift.model.SwiftTagListBlock;
import com.prowidesoftware.swift.model.Tag;
import com.prowidesoftware.swift.utils.SwiftFormatUtils;
import org.apache.commons.lang3.StringUtils;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.Serializable;
import java.util.*;

/**
* SWIFT MT Field 30I.
Expand All @@ -49,7 +36,7 @@
*
* <p>Subfields (components) Data types
* <ol>
* <li>Component 1: DateorStartDate: <code>Calendar</code></li>
* <li>Component 1: StartDate: <code>Calendar</code></li>
* <li>Component 2: EndDate: <code>Calendar</code></li>
* </ol>
*
Expand Down Expand Up @@ -103,9 +90,16 @@ public class Field30I extends Field implements Serializable, DateContainer {
public static final String TYPES_PATTERN = "DD";

/**
* Component number for the Date or Start Date subfield.
* Component number for the Start Date subfield.
*/
public static final Integer DATE_OR_START_DATE = 1;
public static final Integer START_DATE = 1;

/**
* @deprecated use #START_DATE instead
*/
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public static final Integer DATE_OR_START_DATE = 1;

/**
* Component number for the End Date subfield.
Expand Down Expand Up @@ -322,7 +316,7 @@ public int componentsSize() {
@Override
public List<String> getComponentLabels() {
List<String> result = new ArrayList<>();
result.add("Date or Start Date");
result.add("Start Date");
result.add("End Date");
return result;
}
Expand All @@ -334,7 +328,7 @@ public List<String> getComponentLabels() {
@Override
protected Map<Integer, String> getComponentMap() {
Map<Integer, String> result = new HashMap<>();
result.put(1, "dateorStartDate");
result.put(1, "startDate");
result.put(2, "endDate");
return result;
}
Expand All @@ -350,13 +344,15 @@ protected Map<String, Integer> getLabelMap() {
return super.labelMap;
}
super.labelMap = new HashMap<>();
super.labelMap.put("startdate", 1);
// alias name
super.labelMap.put("dateorstartdate", 1);
super.labelMap.put("enddate", 2);
return super.labelMap;
}

/**
* Gets the component 1 (Date or Start Date).
* Gets the component 1 (Start Date).
* @return the component 1
*/
public String getComponent1() {
Expand All @@ -373,21 +369,41 @@ public java.util.Calendar getComponent1AsCalendar() {
}

/**
* Gets the Date or Start Date (component 1).
* @return the Date or Start Date from component 1
* Gets the Start Date (component 1).
* @return the Start Date from component 1
*/
public String getDateorStartDate() {
public String getStartDate() {
return getComponent1();
}

/**
* Get the Date or Start Date (component 1) as Calendar
* @return the Date or Start Date from component 1 converted to Calendar or null if cannot be converted
* Alternative <em>DEPRECATED</em> method getter for field's Start Date
* @deprecated use #getStartDate() instead
* @since 9.2.7
*/
public java.util.Calendar getDateorStartDateAsCalendar() {
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public String getDateorStartDate() {
return getStartDate();
}

/**
* Get the Start Date (component 1) as Calendar
* @return the Start Date from component 1 converted to Calendar or null if cannot be converted
*/
public java.util.Calendar getStartDateAsCalendar() {
return getComponent1AsCalendar();
}

/**
* @deprecated use #getStartDateAsCalendar() instead
*/
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public java.util.Calendar getDateorStartDateAsCalendar() {
return getStartDateAsCalendar();
}

/**
* Gets the component 2 (End Date).
* @return the component 2
Expand Down Expand Up @@ -422,9 +438,9 @@ public java.util.Calendar getEndDateAsCalendar() {
}

/**
* Set the component 1 (Date or Start Date).
* Set the component 1 (Start Date).
*
* @param component1 the Date or Start Date to set
* @param component1 the Start Date to set
* @return the field object to enable build pattern
*/
public Field30I setComponent1(String component1) {
Expand All @@ -435,7 +451,7 @@ public Field30I setComponent1(String component1) {
/**
* Set the component1 from a Calendar object.
*
* @param component1 the Calendar with the Date or Start Date content to set
* @param component1 the Calendar with the Start Date content to set
* @return the field object to enable build pattern
*/
public Field30I setComponent1(java.util.Calendar component1) {
Expand All @@ -444,27 +460,45 @@ public Field30I setComponent1(java.util.Calendar component1) {
}

/**
* Set the Date or Start Date (component 1).
* Set the Start Date (component 1).
*
* @param component1 the Date or Start Date to set
* @param component1 the Start Date to set
* @return the field object to enable build pattern
*/
public Field30I setDateorStartDate(String component1) {
public Field30I setStartDate(String component1) {
return setComponent1(component1);
}

/**
* Set the Date or Start Date (component 1) from a Calendar object.
* Set the Start Date (component 1) from a Calendar object.
*
* @see #setComponent1(java.util.Calendar)
*
* @param component1 Calendar with the Date or Start Date content to set
* @param component1 Calendar with the Start Date content to set
* @return the field object to enable build pattern
*/
public Field30I setDateorStartDate(java.util.Calendar component1) {
public Field30I setStartDate(java.util.Calendar component1) {
return setComponent1(component1);
}

/**
* @deprecated use #setStartDate(String) instead
*/
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public Field30I setDateorStartDate(String component1) {
return setStartDate(component1);
}

/**
* @deprecated use #setComponent1(java.util.Calendar) instead
*/
@Deprecated
@ProwideDeprecated(phase4 = TargetYear.SRU2024)
public Field30I setDateorStartDate(java.util.Calendar component1) {
return setStartDate(component1);
}

/**
* Set the component 2 (End Date).
*
Expand Down Expand Up @@ -613,12 +647,18 @@ public static Field30I fromJson(final String json) {

final JsonObject jsonObject = JsonParser.parseString(json).getAsJsonObject();

// **** COMPONENT 1 - Date or Start Date
// **** COMPONENT 1 - Start Date

// first try using alias's names (including deprecated ones, if any)
if (jsonObject.get("dateorStartDate") != null) {
field.setComponent1(jsonObject.get("dateorStartDate").getAsString());
}

// last try using the official component's name (overwrites alternatives and DEPRECATED)
if (jsonObject.get("startDate") != null) {
field.setComponent1(jsonObject.get("startDate").getAsString());
}

// **** COMPONENT 2 - End Date

if (jsonObject.get("endDate") != null) {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/prowidesoftware/swift/model/BIC.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,11 @@ public String distinguishedName() {
* @since 9.3.15
*/
public String distinguishedName(boolean includeDefaultBranch) {
StringBuilder result = new StringBuilder();
DistinguishedName.Builder dnBuilder = new DistinguishedName.Builder(getBic8());
if (includeDefaultBranch || !Objects.equals(getBranchOrDefault(), "XXX")) {
result.append("ou=")
.append(StringUtils.lowerCase(getBranchOrDefault()))
.append(",");
dnBuilder.withBranch(getBranchOrDefault());
}
result.append("o=").append(StringUtils.lowerCase(getBic8())).append(",o=swift");
return result.toString();
return dnBuilder.build().toString();
}

@Override
Expand Down
Loading

0 comments on commit e96050d

Please sign in to comment.