Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capitalization of field names #122

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public with sharing class MobileMapLayersService {
input = '%' + input + '%';
if (isQuotesNeeded(fieldType))
input = '\'' + input + '\'';
if (fieldType == 'TIME')
if (fieldType == 'Time')
input += 'Z';
String operator = isLikeNeeded(fieldType) ? 'LIKE' : '=';

Expand Down Expand Up @@ -81,29 +81,29 @@ public with sharing class MobileMapLayersService {

private static boolean isQuotesNeeded(String type) {
List<String> types = new List<String>{
'DATE',
'TIME',
'DATETIME',
'BOOLEAN',
'DOUBLE',
'INTEGER',
'CURRENCY',
'PERCENT'
'Date',
'Time',
'DateTime',
'Boolean',
'Double',
'Integer',
'Currency',
'Percent'
};
return !types.contains(type);
}

private static boolean isLikeNeeded(String type) {
List<String> types = new List<String>{
'DATE',
'TIME',
'DATETIME',
'BOOLEAN',
'DOUBLE',
'INTEGER',
'CURRENCY',
'PERCENT',
'REFERENCE'
'Date',
'Time',
'DateTime',
'Boolean',
'Double',
'Integer',
'Currency',
'Percent',
'Reference'
};
return !types.contains(type);
}
Expand All @@ -114,7 +114,7 @@ public with sharing class MobileMapLayersService {
String operator,
String input
) {
if (fieldType != 'DATETIME')
if (fieldType != 'DateTime')
return field + ' ' + operator + ' ' + input;

// for dateTime fields - search whole day, user don't need to put in the exact time
Expand All @@ -141,24 +141,24 @@ public with sharing class MobileMapLayersService {
private static String castToType(String input, String fieldType) {
try {
switch on fieldType {
when 'TIME' {
when 'Time' {
Pattern MyPattern = Pattern.compile('\\d\\d:\\d\\d:\\d\\d.\\d\\d\\d');
Matcher MyMatcher = MyPattern.matcher(input);
if (MyMatcher.matches())
return input;
else
return '';
}
when 'DATE', 'DATETIME' {
when 'Date', 'DateTime' {
return String.valueOf(Date.valueOf(input));
}
when 'BOOLEAN' {
when 'Boolean' {
return String.valueOf(Boolean.valueOf(input));
}
when 'INTEGER' {
when 'Integer' {
return String.valueOf(Integer.valueOf(input));
}
when 'DOUBLE', 'CURRENCY', 'PERCENT' {
when 'Double', 'Currency', 'Percent' {
return String.valueOf(Double.valueOf(input));
}
when else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public with sharing class MobileMapLayersServiceTest {
static void executeFilterQueryTest() {
try {
Map<String, String> currentFieldFilter = new Map<String, String>();
currentFieldFilter.put('type', 'STRING');
currentFieldFilter.put('type', 'String');
currentFieldFilter.put('value', 'name');
currentFieldFilter.put('input', 'Resource Name');
List<sObject> result = MobileMapLayersService.executeFilterQuery(
Expand All @@ -36,7 +36,7 @@ public with sharing class MobileMapLayersServiceTest {
static void executeFilterQueryInvalidInputTest() {
try {
Map<String, String> currentFieldFilter = new Map<String, String>();
currentFieldFilter.put('type', 'DOUBLE');
currentFieldFilter.put('type', 'Double');
currentFieldFilter.put('value', 'lastknownlatitude');
currentFieldFilter.put('input', 'text');
MobileMapLayersService.executeFilterQuery(
Expand Down
Loading