Skip to content

Commit

Permalink
- FIX: Fixed some issues with server info enums.
Browse files Browse the repository at this point in the history
- CHG: Preparation for bugfix release.
  • Loading branch information
sebastian-raubach committed Mar 10, 2021
1 parent f324510 commit c7b514e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'uk.ac.hutton.ics'
version '1.0.1'
version '1.0.2'

sourceCompatibility = 11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public class BaseResult<T>
private Metadata metadata = new Metadata();
private T result;

public BaseResult()
{
}

public BaseResult(T result, int currentPage, int pageSize, long totalCount)
{
this.result = result;
Expand Down
38 changes: 34 additions & 4 deletions src/main/java/uk/ac/hutton/ics/brapi/resource/base/BrapiCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public BrapiCall addVersion(Version version)

public boolean hasDataType(DataType datatype)
{
return dataTypes.contains(datatype.name());
return dataTypes.contains(datatype.getType());
}

public boolean hasMethod(Method method)
Expand All @@ -49,7 +49,7 @@ public boolean hasMethod(Method method)

public boolean hasVersion(Version version)
{
return versions.contains(version.name());
return versions.contains(version.getNumber());
}

public String getService()
Expand All @@ -65,7 +65,7 @@ public BrapiCall setService(String service)

public List<DataType> getDataTypes()
{
return dataTypes.stream().map(DataType::valueOf).collect(Collectors.toList());
return dataTypes.stream().map(DataType::getFromString).collect(Collectors.toList());
}

public List<Method> getMethods()
Expand All @@ -75,7 +75,7 @@ public List<Method> getMethods()

public List<Version> getVersions()
{
return versions.stream().map(Version::valueOf).collect(Collectors.toList());
return versions.stream().map(Version::getFromString).collect(Collectors.toList());
}

public enum DataType
Expand All @@ -90,6 +90,21 @@ public enum DataType
{
this.type = type;
}

public String getType() {
return type;
}

public static DataType getFromString(String type)
{
for (DataType dt : DataType.values())
{
if (Objects.equals(dt.type, type))
return dt;
}

return null;
}
}

public enum Method
Expand All @@ -114,5 +129,20 @@ public enum Version
{
this.number = number;
}

public String getNumber() {
return number;
}

public static Version getFromString(String version)
{
for (Version v : Version.values())
{
if (Objects.equals(v.number, version))
return v;
}

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public TokenPagination(int pageSize, String currentPageToken, long totalCount, i
this.totalCount = totalCount;
this.totalPages = (int) Math.ceil(totalCount / (float) desiredPageSize);

// If we can, generate valeus for prevPageToken and nextPageToken
// If we can, generate values for prevPageToken and nextPageToken
int currentPage = Integer.parseInt(currentPageToken);
if (currentPage >= 1)
prevPageToken = String.valueOf(currentPage - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class ServerInfo
private String serverDescription;
private String serverName;

public ServerInfo()
{
}

public List<BrapiCall> getCalls()
{
return calls;
Expand Down

0 comments on commit c7b514e

Please sign in to comment.