leap_salesforce 1.4.2 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.leap_salesforce.yml +3 -2
- data/ChangeLog +7 -0
- data/README.md +2 -0
- data/exe/leap_salesforce +19 -0
- data/lib/leap_salesforce/generator/soql_enums.rb +38 -17
- data/lib/leap_salesforce/generator/templates/picklist.java.erb +23 -0
- data/lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb +5 -7
- data/lib/leap_salesforce/parameters.rb +7 -0
- data/lib/leap_salesforce/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d138756e5cde80ef7fb59d3ac68f940781ee7e2c92f0653760d789d4f6faf1c9
|
4
|
+
data.tar.gz: 1ee8719c4fc3b2ee6b632a4e8e5a6c8aaa80d8c0b8ca4131d7ccaa92142e2c29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a916d78dcb5df8732d9ffd3f6e692801b17307ef32aa1e0a9046bcd64db5d28075ac0b7bac36d3ea0b4e0119a327376aa2f1e05889ae8f9acfe6cfcdf77e4f
|
7
|
+
data.tar.gz: a0756ee544ec6389d4c18bf6dce18ae2ffbaa36e75f1ccb16e0c89c5fbca82f0a06469d9fb3afa8b6110574992a2c8f2c4c96550cb0dbdf9a50ab05fc43d57b7
|
data/.leap_salesforce.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
environment: prod # This is irrelevant for sfdx auth which uses user/alias
|
2
2
|
lib_folder: spec/support
|
3
|
+
# enum_folder: spec/support/enum
|
3
4
|
sfdx: false
|
4
5
|
# Example of settings for generating Java classes
|
5
6
|
# language: java
|
6
|
-
# soql_field_start_text:
|
7
|
-
#
|
7
|
+
# soql_field_start_text: package com.salesforce.test.pojo.soqlObjects;
|
8
|
+
# soql_enum_start_text: package com.salesforce.test.enums
|
8
9
|
soql_objects:
|
9
10
|
- Case
|
10
11
|
- Contact
|
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Version 1.4.4
|
2
|
+
* Java POMO set boolean type when object type is 'boolean' instead of 'String'
|
3
|
+
|
4
|
+
Version 1.4.3
|
5
|
+
* Simplify Java POMO's created using Lombok
|
6
|
+
* Add executable to create enum objects in Java with 'leap_salesforce create_soql_enums' and 'leap_salesforce create_all' that creates both objects and enums
|
7
|
+
|
1
8
|
Version 1.4.2
|
2
9
|
* Fixed leap_salesforce version method
|
3
10
|
|
data/README.md
CHANGED
@@ -224,6 +224,8 @@ RSpec.describe 'Picklists' do
|
|
224
224
|
end
|
225
225
|
```
|
226
226
|
|
227
|
+
One can also create this using the executable, e.g `leap_salesforce create_soql_enums`.
|
228
|
+
|
227
229
|
#### Changing environment
|
228
230
|
|
229
231
|
The `LEAP_ENV` environment variable can be used to change environment in non sfdx mode. The default is set through
|
data/exe/leap_salesforce
CHANGED
@@ -71,6 +71,25 @@ Please ignore "config/credentials/" and "logs/"'.colorize :red
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
desc 'create_soql_enums', 'Creates enum objects for SOQL objects from metadata based on .leap_salesforce.yml'
|
75
|
+
option :language
|
76
|
+
def create_soql_enums(check_auth = true)
|
77
|
+
LeapSalesforce.language = options[:language] if options[:language]
|
78
|
+
require 'leap_salesforce/generator/soql_enums'
|
79
|
+
LeapSalesforce::Users.execute_as_if_present key: :admin do
|
80
|
+
LeapSalesforce::Generator::SoqlEnums.new.create
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'create_all', 'Creates SOQL objects and enum objects from metadata based on .leap_salesforce.yml'
|
85
|
+
option :language
|
86
|
+
def create_all
|
87
|
+
puts 'Creating soql objects'.colorize :yellow
|
88
|
+
create_soql_objects
|
89
|
+
puts 'Creating soql enums'.colorize :yellow
|
90
|
+
create_soql_enums
|
91
|
+
end
|
92
|
+
|
74
93
|
desc 'version', 'Version this library'
|
75
94
|
def version
|
76
95
|
puts LeapSalesforce::VERSION
|
@@ -1,26 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'soql_objects'
|
4
|
+
require_relative '../soql_data/soql_data'
|
4
5
|
|
5
6
|
module LeapSalesforce
|
6
7
|
# Generators for creating code
|
7
8
|
module Generator
|
8
|
-
# Creates Soql Enumerations / Picklists from objects in LeapSalesforce.
|
9
|
+
# Creates Soql Enumerations / Picklists from objects in LeapSalesforce.soql_objects
|
9
10
|
class SoqlEnums
|
10
11
|
include Generator
|
11
12
|
|
12
13
|
# @return [String] Folder where enumeration objects are stored
|
13
|
-
|
14
|
+
if LeapSalesforce.enum_folder
|
15
|
+
ENUM_FOLDER = LeapSalesforce.enum_folder
|
16
|
+
else
|
17
|
+
ENUM_FOLDER = File.join(LeapSalesforce.lib_folder, 'metadata', 'enum').freeze
|
18
|
+
end
|
14
19
|
|
15
|
-
# Create Soql enumerations for all objects specified
|
20
|
+
# Create Soql enumerations for all objects specified in .leap_salesforce.yml
|
16
21
|
def create
|
17
|
-
if LeapSalesforce.
|
18
|
-
raise LeapSalesforce::SetupError, 'LeapSalesforce.
|
19
|
-
'Please set the list of objects you want to
|
22
|
+
if LeapSalesforce.soql_objects.empty?
|
23
|
+
raise LeapSalesforce::SetupError, 'LeapSalesforce.soql_objects is empty. ' \
|
24
|
+
'Please set the list of objects you want to create enums for in .leap_salesforce:soql_objects ' \
|
20
25
|
'and then run task "leaps:create_soql_objects" to create objects'
|
21
26
|
end
|
22
27
|
reset_enum_folder
|
23
|
-
LeapSalesforce.
|
28
|
+
LeapSalesforce.soql_objects.each { |entity| create_picklists_for entity }
|
24
29
|
cleanup_files_created
|
25
30
|
end
|
26
31
|
|
@@ -28,16 +33,23 @@ module LeapSalesforce
|
|
28
33
|
# @param [LeapSalesforce::SoqlData] entity An object representing an object in Salesforce
|
29
34
|
# Object inheriting from SoqlData that has picklists underneath it
|
30
35
|
def create_picklists_for(entity)
|
31
|
-
soql_object = LeapSalesforce.soql_objects.find { |so| so.class_name == entity.to_s }
|
32
|
-
|
33
|
-
|
36
|
+
soql_object = entity # LeapSalesforce.soql_objects.find { |so| so.class_name == entity.to_s }
|
37
|
+
@soql_data_object = Class.new(SoqlData) do
|
38
|
+
soql_object soql_object.backend_name
|
39
|
+
end
|
40
|
+
@entity_name = entity.class_name
|
41
|
+
unless soql_object
|
42
|
+
LeapSalesforce.logger.warn "Could not find soql object for '#{@entity_name}', ignoring"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
34
46
|
unless soql_object.create_enum != false
|
35
|
-
puts "Skipping picklists for #{
|
47
|
+
puts "Skipping picklists for #{@entity_name}"
|
36
48
|
return
|
37
49
|
end
|
38
|
-
puts "Creating picklists for #{
|
39
|
-
|
40
|
-
picklists =
|
50
|
+
puts "Creating picklists for #{@entity_name}"
|
51
|
+
|
52
|
+
picklists = @soql_data_object.picklists
|
41
53
|
puts "#{picklists.count} picklists found"
|
42
54
|
picklists.each do |picklist|
|
43
55
|
if soql_object.excludes?(picklist)
|
@@ -53,13 +65,20 @@ module LeapSalesforce
|
|
53
65
|
@picklist = picklist
|
54
66
|
@enum_name = picklist.to_class_name
|
55
67
|
picklist_name = picklist.to_key_name
|
56
|
-
values = @
|
68
|
+
values = @soql_data_object.picklist_for(picklist)
|
57
69
|
@enum_values = {}
|
58
70
|
values.each do |value|
|
59
71
|
@enum_values[value.to_key_name_for(@enum_values)] = value
|
60
72
|
end
|
61
|
-
|
62
|
-
|
73
|
+
if LeapSalesforce.language == "ruby"
|
74
|
+
content = read_template 'picklist.rb.erb', binding
|
75
|
+
file = File.join(ENUM_FOLDER, @entity_name.to_s.snakecase, "#{picklist_name}.rb")
|
76
|
+
elsif LeapSalesforce.language == 'java'
|
77
|
+
content = read_template 'picklist.java.erb', binding
|
78
|
+
file = File.join(ENUM_FOLDER, @entity_name.to_s, "#{@enum_name}.java")
|
79
|
+
else
|
80
|
+
raise LeapSalesforce::SetupError, "Unsupported language '#{LeapSalesforce.language}'"
|
81
|
+
end
|
63
82
|
generate_file file, content
|
64
83
|
end
|
65
84
|
|
@@ -70,6 +89,8 @@ module LeapSalesforce
|
|
70
89
|
|
71
90
|
# Clean up files generated for all picklists
|
72
91
|
def cleanup_files_created
|
92
|
+
return unless LeapSalesforce.language == "ruby"
|
93
|
+
|
73
94
|
`rubocop -A #{ENUM_FOLDER} --display-only-fail-level-offenses --enable-pending-cops`
|
74
95
|
end
|
75
96
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= LeapSalesforce.soql_enum_start_text %>.<%= @entity_name %>;
|
2
|
+
|
3
|
+
/** This file is generated and updated automatically so best not to edit manually
|
4
|
+
* Helps handle picklist values for <%= "#{@entity_name}, #{@enum_name}" %>
|
5
|
+
*/
|
6
|
+
public enum <%= @enum_name %> {
|
7
|
+
<% @enum_values.each_with_index do |value, index| %>
|
8
|
+
<%= value[0].camelize(:upper).to_s %>("<%= value[1] %>")<%= index == @enum_values.length - 1 ? ';' : ',' %><% end%>
|
9
|
+
|
10
|
+
private String displayName;
|
11
|
+
|
12
|
+
public String displayName() { return displayName; }
|
13
|
+
|
14
|
+
@Override public String toString() { return displayName; }
|
15
|
+
|
16
|
+
<%= @enum_name %>(String displayName) {
|
17
|
+
this.displayName = displayName;
|
18
|
+
}
|
19
|
+
|
20
|
+
public static <%= @enum_name %> getRandom() {
|
21
|
+
return values()[(int) (Math.random() * values().length)];
|
22
|
+
}
|
23
|
+
}
|
@@ -2,24 +2,22 @@
|
|
2
2
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
3
3
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
4
4
|
|
5
|
+
import lombok.Data;
|
6
|
+
|
5
7
|
/**
|
6
8
|
* Auto-generated code created by leap_salesforce. Do not manually
|
7
9
|
* update as this can be overwritten when `leap_salesforce create_soql_objects` is run
|
8
10
|
*/
|
9
11
|
@JsonIgnoreProperties(ignoreUnknown=true)
|
12
|
+
@Data
|
10
13
|
public class <%= @soql_object.class_name %> {
|
11
14
|
|
12
15
|
<% @soql_class.fields.each do |field| %>
|
13
|
-
@JsonProperty(value="<%= field['name'] %>")
|
14
|
-
String <%= field['name'].camelize(:lower) %>;
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
<% @soql_class.fields.each do |field| %>
|
18
|
-
public String get<%= field['name'].camelize(:upper) %>() { return <%= field['name'].camelize(:lower) %>; }
|
19
16
|
/**
|
20
17
|
* Label: '<%= field['label'] %>', Type: <%= field['type'] %><%= ", Relationship:" + field['relationshipName'] if field['relationshipName'] %>
|
21
18
|
*/
|
22
|
-
|
19
|
+
@JsonProperty(value="<%= field['name'] %>")
|
20
|
+
<%= field['type'] == 'boolean' ? 'Boolean' : 'String' %> <%= field['name'].camelize(:lower) %>;
|
23
21
|
<% end %>
|
24
22
|
}
|
25
23
|
|
@@ -11,6 +11,7 @@ CREATE_APP_LINK = 'https://trailhead.salesforce.com/content/learn/projects/autom
|
|
11
11
|
module LeapSalesforce
|
12
12
|
@config_folder = 'config'
|
13
13
|
@lib_folder = File.join('lib', 'leap_salesforce').freeze
|
14
|
+
@enum_folder = nil
|
14
15
|
@objects_to_verify = []
|
15
16
|
@soql_objects = []
|
16
17
|
@client_id = ENV['client_id']
|
@@ -18,6 +19,7 @@ module LeapSalesforce
|
|
18
19
|
@password = ENV['password']
|
19
20
|
@language = 'ruby'
|
20
21
|
@soql_field_start_text = ''
|
22
|
+
@soql_enum_start_text = ''
|
21
23
|
@environment = nil
|
22
24
|
@logger = Logger.new $stdout
|
23
25
|
@sfdx = false
|
@@ -124,6 +126,8 @@ module LeapSalesforce
|
|
124
126
|
attr_accessor :security_token
|
125
127
|
# @return [String] Path where library generated assets are stored. By default lib/leap_salesforce
|
126
128
|
attr_accessor :lib_folder
|
129
|
+
# @return [String] Path where generated enum files are stored. By default this is null and just appeneded to lib_folder
|
130
|
+
attr_accessor :enum_folder
|
127
131
|
# @return [Array] List of objects to verify metadata for. This includes enums, required values
|
128
132
|
# Changes to these values will need to be version controlled
|
129
133
|
attr_accessor :objects_to_verify
|
@@ -139,6 +143,9 @@ module LeapSalesforce
|
|
139
143
|
# classes in the Salesforce object
|
140
144
|
attr_accessor :soql_field_start_text
|
141
145
|
|
146
|
+
# @return [String] Text to be added as start of auto generated Soql enums
|
147
|
+
attr_accessor :soql_enum_start_text
|
148
|
+
|
142
149
|
# @return [Array] list_of_soql_objects Array describing Soql objects taken from .leap_salesforce.yml
|
143
150
|
def soql_objects=(list_of_soql_objects)
|
144
151
|
@soql_objects = list_of_soql_objects.collect do |soql_object_desc|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -358,6 +358,7 @@ files:
|
|
358
358
|
- lib/leap_salesforce/generator/templates/config/environments/specific_file.rb.erb
|
359
359
|
- lib/leap_salesforce/generator/templates/config/general.rb.erb
|
360
360
|
- lib/leap_salesforce/generator/templates/factory.rb.erb
|
361
|
+
- lib/leap_salesforce/generator/templates/picklist.java.erb
|
361
362
|
- lib/leap_salesforce/generator/templates/picklist.rb.erb
|
362
363
|
- lib/leap_salesforce/generator/templates/soql_object.rb.erb
|
363
364
|
- lib/leap_salesforce/generator/templates/soql_object_field_names.Java.erb
|