Skip to content

Commit

Permalink
Merge pull request #122 from rotem-hen-sf/main
Browse files Browse the repository at this point in the history
Fix capitalization of field names
  • Loading branch information
maliroteh-sf authored Apr 17, 2024
2 parents bb6cfbd + ee7d079 commit 037b2ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
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

0 comments on commit 037b2ab

Please sign in to comment.