lucid_works 0.7.18 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +2 -3
- data/Gemfile +2 -8
- data/Gemfile.lock +45 -53
- data/README.rdoc +2 -6
- data/Rakefile +1 -1
- data/config/locales/en.yml +221 -239
- data/lib/lucid_works/activity.rb +8 -5
- data/lib/lucid_works/base.rb +27 -16
- data/lib/lucid_works/cache.rb +13 -0
- data/lib/lucid_works/cluster.rb +84 -0
- data/lib/lucid_works/collection/settings.rb +15 -6
- data/lib/lucid_works/collection.rb +62 -92
- data/lib/lucid_works/datasource/history.rb +2 -1
- data/lib/lucid_works/datasource/mapping.rb +12 -0
- data/lib/lucid_works/datasource/schedule.rb +5 -2
- data/lib/lucid_works/datasource/status.rb +3 -2
- data/lib/lucid_works/datasource.rb +31 -48
- data/lib/lucid_works/datasource_property.rb +2 -1
- data/lib/lucid_works/datasource_type.rb +14 -0
- data/lib/lucid_works/dynamicfield.rb +12 -0
- data/lib/lucid_works/elevation.rb +93 -0
- data/lib/lucid_works/exceptions.rb +0 -4
- data/lib/lucid_works/field.rb +31 -111
- data/lib/lucid_works/field_commons.rb +133 -0
- data/lib/lucid_works/gem_version.rb +1 -1
- data/lib/lucid_works/inflections.rb +3 -0
- data/lib/lucid_works/patch_time.rb +4 -0
- data/lib/lucid_works/request_handler.rb +16 -0
- data/lib/lucid_works/role.rb +23 -8
- data/lib/lucid_works/schema/attribute.rb +1 -1
- data/lib/lucid_works/schema/boolean_attribute.rb +1 -1
- data/lib/lucid_works/schema/integer_attribute.rb +3 -4
- data/lib/lucid_works/server/crawlers_status.rb +15 -0
- data/lib/lucid_works/server.rb +35 -14
- data/lib/lucid_works/simple_naming.rb +1 -7
- data/lib/lucid_works/synonym.rb +1 -1
- data/lib/lucid_works/version.rb +1 -0
- data/lib/lucid_works.rb +8 -1
- data/lucid_works.gemspec +8 -9
- data/spec/fixtures/zookeeper/clusterstate.json +30 -0
- data/spec/fixtures/zookeeper/clusterstate_broken_shard.json +29 -0
- data/spec/fixtures/zookeeper/live_nodes.json +28 -0
- data/spec/fixtures/zookeeper/live_nodes_no_children.json +26 -0
- data/spec/fixtures/zookeeper/live_nodes_one_child.json +36 -0
- data/spec/lib/lucid_works/base_spec.rb +33 -24
- data/spec/lib/lucid_works/cache_spec.rb +44 -0
- data/spec/lib/lucid_works/cluster_spec.rb +109 -0
- data/spec/lib/lucid_works/collection/activity_spec.rb +29 -0
- data/spec/lib/lucid_works/collection/prime_activities_spec.rb +1 -1
- data/spec/lib/lucid_works/collection/settings_spec.rb +31 -0
- data/spec/lib/lucid_works/collection_spec.rb +166 -107
- data/spec/lib/lucid_works/datasource/schedule_spec.rb +75 -46
- data/spec/lib/lucid_works/datasource/status_spec.rb +5 -5
- data/spec/lib/lucid_works/datasource_property_spec.rb +41 -0
- data/spec/lib/lucid_works/datasource_spec.rb +40 -12
- data/spec/lib/lucid_works/datasource_type_spec.rb +31 -0
- data/spec/lib/lucid_works/dynamicfield_spec.rb +214 -0
- data/spec/lib/lucid_works/elevation_spec.rb +175 -0
- data/spec/lib/lucid_works/field_spec.rb +52 -21
- data/spec/lib/lucid_works/fieldtype_spec.rb +0 -1
- data/spec/lib/lucid_works/request_handler_spec.rb +11 -0
- data/spec/lib/lucid_works/role_spec.rb +77 -0
- data/spec/lib/lucid_works/server/crawlers_status_spec.rb +21 -0
- data/spec/lib/lucid_works/server_spec.rb +123 -22
- data/spec/lib/lucid_works/{collection/synonym_spec.rb → synonym_spec.rb} +23 -22
- data/spec/lib/lucid_works/version_spec.rb +6 -0
- metadata +132 -64
- data/spec/lib/lucid_works/collection/acl_config_spec.rb +0 -212
data/config/locales/en.yml
CHANGED
@@ -6,140 +6,187 @@ en:
|
|
6
6
|
# and is used by human_attribute_name
|
7
7
|
#
|
8
8
|
attributes:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
9
|
+
collection:
|
10
|
+
name: Name
|
11
|
+
num_shards: Number of shards
|
12
|
+
collection/info:
|
13
|
+
collection_name: Collection name
|
14
|
+
data_dir: Data directory
|
15
|
+
free_disk_bytes: Free disk bytes
|
16
|
+
free_disk_space: Free disk space
|
17
|
+
index_directory: Index directory
|
18
|
+
index_has_deletions: Index has deletions
|
19
|
+
index_is_current: Index is current
|
20
|
+
index_is_optimized: Optimized
|
21
|
+
index_last_modified: Index last modified
|
22
|
+
index_max_doc: Index max doc
|
23
|
+
index_num_docs: Documents indexed
|
24
|
+
index_size: Index size
|
25
|
+
index_size_bytes: Index size
|
26
|
+
index_version: Index version
|
27
|
+
instance_dir: Instance directory
|
28
|
+
root_dir: Root directory
|
29
|
+
total_disk_bytes: Total disk bytes
|
30
|
+
total_disk_space: Total disk space
|
31
|
+
collection/settings:
|
32
|
+
auto_complete: Auto complete
|
33
|
+
boost_recent: Boost recent
|
34
|
+
boosts: Boosts
|
35
|
+
click_boost_data: Click boost data
|
36
|
+
click_boost_field: Click boost field
|
37
|
+
click_enabled: Click scoring enabled
|
38
|
+
de_duplication: De-duplication
|
39
|
+
default_sort: Default sort
|
40
|
+
display_facets: Display facets
|
41
|
+
elevations: elevations
|
42
|
+
index_time_stopwords: Exclude stop words from index
|
43
|
+
main_index_ram_buffer_size_mb: RAM buffer size (MB)
|
44
|
+
main_index_merge_factor: Merge factor
|
45
|
+
query_parser: Query parser
|
46
|
+
query_time_stopwords: Include stop words in searches
|
47
|
+
query_time_synonyms: Use synonyms
|
48
|
+
search_server_list: Search server list
|
49
|
+
show_similar: Show "find similar" links
|
50
|
+
spellcheck: Spell-check
|
51
|
+
ssl: SSL
|
52
|
+
stopword_list: Stopword list
|
53
|
+
synonym_list: Synonym list
|
54
|
+
unknown_type_handling: Default field type
|
55
|
+
unsupervised_feedback: Unsupervised feedback
|
56
|
+
unsupervised_feedback_emphasis: Unsupervised feedback emphasis
|
57
|
+
update_server_list: Update server list
|
58
|
+
datasource:
|
59
|
+
ad_cache_groups: Cache groups
|
60
|
+
ad_credentials: Credentials
|
61
|
+
ad_group_filter: Group filter
|
62
|
+
ad_url: Active Directory URL
|
63
|
+
ad_user_base_dn: User base DN
|
64
|
+
ad_user_filter: User filter
|
65
|
+
ad_user_principal_name: User principal name
|
66
|
+
ad_group_base_dn: Group base DN
|
67
|
+
aliases: Site Aliases Mappings
|
68
|
+
auth: Authentication credentials
|
69
|
+
authorization: Authorization
|
70
|
+
bounds: Constrain to
|
71
|
+
commit_on_finish: Commit when crawl finishes
|
72
|
+
commit_within: Commit within
|
73
|
+
commit_within_sec: Commit within (seconds)
|
74
|
+
connector_type: Connector Type
|
75
|
+
deleteAfter: Delete logs after
|
76
|
+
delta_sql_query: Delta SQL query
|
77
|
+
domain: Domain
|
78
|
+
enable_security_trimming: Enable security trimming
|
79
|
+
excluded_urls: Excluded URLs
|
80
|
+
fail_unsupported_file_types: Fail unsupported file types
|
81
|
+
feed_unpublished_documents: Feed unpublished documents
|
82
|
+
groupname_format_in_ace: Group name format in ACE
|
83
|
+
host: Domain Name
|
84
|
+
ignore_robots: Ignore robots.txt
|
85
|
+
include_datasource_metadata: Include data source metadata
|
86
|
+
included_urls: Included URLs
|
87
|
+
kdcserver: Kerberos KDC server
|
88
|
+
ldap_auth_type: LDAP authentication type
|
89
|
+
ldap_cache_groups_membership: LDAP cache group membership
|
90
|
+
ldap_cache_refresh_interval: LDAP cache refresh interval
|
91
|
+
ldap_cache_size: LDAP cache size
|
92
|
+
ldap_read_groups_type: LDAP read groups type
|
93
|
+
ldap_search_base: LDAP search base
|
94
|
+
ldap_server_host_address: LDAP server host
|
95
|
+
ldap_server_port_number: LDAP server port
|
96
|
+
ldap_server_use_ssl: LDAP server use SSL
|
97
|
+
log_extra_detail: Log extra detail
|
98
|
+
max_bytes: Skip files larger than (bytes)
|
99
|
+
my_site_base_url: MySite URL
|
100
|
+
output_args: Output arguments
|
101
|
+
output_url: Output URL
|
102
|
+
password: Password
|
103
|
+
proxy_host: Proxy host
|
104
|
+
proxy_password: Proxy password
|
105
|
+
proxy_port: Proxy port
|
106
|
+
proxy_username: Proxy user name
|
107
|
+
push_acls: Push ACLs
|
108
|
+
realm: Realm
|
109
|
+
sharepoint_url: SharePoint URL
|
110
|
+
sleep: Sleep (ms)
|
111
|
+
sql_select_statement: SQL SELECT statement
|
112
|
+
type: Type
|
113
|
+
url: URL
|
114
|
+
use_sp_search_visibility: Use SP Search Visibility
|
115
|
+
username: Username
|
116
|
+
username_format_in_ace: Username format in ACE
|
117
|
+
warn_unknown_mime_types: Log warnings for unknown mime types
|
118
|
+
windowsdomain: Windows domain
|
119
|
+
datasource/history:
|
120
|
+
crawl_started: Started
|
121
|
+
crawl_state: State
|
122
|
+
crawl_stopped: Stopped
|
123
|
+
num_deleted: Deleted
|
124
|
+
num_failed: Failed
|
125
|
+
num_new: New
|
126
|
+
num_unchanged: Unchanged
|
127
|
+
num_updated: Updated
|
128
|
+
num_not_found: Not found
|
129
|
+
num_filter_denied: Filter denied
|
130
|
+
num_access_denied: Access denied
|
131
|
+
num_robots_denied: Robots denied
|
132
|
+
datasource/status:
|
133
|
+
crawl_started: Last crawl started
|
134
|
+
crawl_state: State
|
135
|
+
crawl_stopped: Last crawl stopped
|
136
|
+
doc_count: Documents indexed
|
137
|
+
job_id: Job ID
|
138
|
+
num_deleted: Deleted docs
|
139
|
+
num_failed: Failed docs
|
140
|
+
num_new: New docs
|
141
|
+
num_total: Total docs
|
142
|
+
num_unchanged: Unchanged docs
|
143
|
+
num_updated: Updated docs
|
144
|
+
num_not_found: Not found docs
|
145
|
+
num_filter_denied: Filter denied docs
|
146
|
+
num_access_denied: Access denied docs
|
147
|
+
num_robots_denied: Robots denied docs
|
148
|
+
field:
|
149
|
+
copy_fields: Copy this field to fields
|
150
|
+
default_boost: Default boost
|
151
|
+
default_value: Default value
|
152
|
+
dynamic_base: Dynamically generated from
|
153
|
+
editable: Editable
|
154
|
+
facet: Facet
|
155
|
+
field_type: Field type
|
156
|
+
highlight: Highlight
|
157
|
+
include_in_results: Include in results
|
158
|
+
index_for_autocomplete: Index for autocomplete
|
159
|
+
index_for_spellcheck: Index for spell checking
|
160
|
+
indexing_options: Index term frequencies and positions
|
161
|
+
indexed: Indexed
|
162
|
+
multi_valued: Multi-valued
|
163
|
+
name: Name
|
164
|
+
omit_positions: Omit positions
|
165
|
+
omit_tf: Omit term frequencies and positions
|
166
|
+
query_time_stopword_handling: Enable stopword handling
|
167
|
+
search_by_default: Search by default
|
168
|
+
short_field_boost: Short field boost
|
169
|
+
stored: Stored
|
170
|
+
synonym_expasion: Enable synonym expansion
|
171
|
+
term_vectors: Term vectors
|
172
|
+
use_for_deduplication: Use for de-duplication
|
173
|
+
use_in_find_similar: Use in 'find similar'
|
174
|
+
dynamicfield:
|
175
|
+
copy_fields: Copy this field to fields
|
176
|
+
field_type: Field type
|
177
|
+
index_for_autocomplete: Index for autocomplete
|
178
|
+
index_for_spellcheck: Index for spell checking
|
179
|
+
indexing_options: Index term frequencies and positions
|
180
|
+
indexed: Indexed
|
181
|
+
multi_valued: Multi-valued
|
182
|
+
name: Name
|
183
|
+
omit_positions: Omit positions
|
184
|
+
omit_tf: Omit term frequencies and positions
|
185
|
+
stored: Stored
|
186
|
+
term_vectors: Term vectors
|
187
|
+
fieldtype:
|
188
|
+
name: Name
|
189
|
+
_class: Class
|
143
190
|
#
|
144
191
|
# This section containts two things:
|
145
192
|
# Model names wich support ActiveModel <model>.model_name.human
|
@@ -148,112 +195,47 @@ en:
|
|
148
195
|
# or from class LucidWorks::Base.human_attribute_value(attribute, value)
|
149
196
|
#
|
150
197
|
models:
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
optimize: Optimize index
|
159
|
-
collection:
|
160
|
-
one: Collection
|
161
|
-
other: Collections
|
162
|
-
settings:
|
163
|
-
de_duplication:
|
164
|
-
'off': 'Off'
|
165
|
-
overwrite: Overwrite
|
166
|
-
tag: Tag
|
167
|
-
one: Settings
|
168
|
-
other: Settings
|
169
|
-
datasource:
|
170
|
-
one: Data source
|
171
|
-
other: Data sources
|
172
|
-
status:
|
173
|
-
crawl_state:
|
174
|
-
ABORTED: Aborted
|
175
|
-
ABORTING: Aborting
|
176
|
-
EXCEPTION: Exception
|
177
|
-
FINISHED: Finished
|
178
|
-
IDLE: Idle
|
179
|
-
RUNNING: Running
|
180
|
-
STOPPED: Stopped
|
181
|
-
STOPPING: Stopping
|
182
|
-
type:
|
183
|
-
external: External
|
184
|
-
file: File system
|
185
|
-
ftp: FTP
|
186
|
-
hdfs: Hadoop file system
|
187
|
-
jdbc: Database
|
188
|
-
kfs: Kosmos file system
|
189
|
-
lucidworkslogs: LucidWorks Solr Logs
|
190
|
-
s3: Hadoop S3 Block FS
|
191
|
-
s3n: Hadoop S3 Native FS
|
192
|
-
sharepoint: SharePoint
|
193
|
-
smb: Windows Share
|
194
|
-
solrxml: Solr XML
|
195
|
-
web: Web site
|
196
|
-
field:
|
197
|
-
one: Field
|
198
|
-
other: Fields
|
199
|
-
indexing_options:
|
200
|
-
document_only: none
|
201
|
-
document_termfreq: term frequencies
|
202
|
-
document_termfreq_termpos: term frequencies and positions
|
203
|
-
fieldtype:
|
204
|
-
one: Field type
|
205
|
-
other: Field types
|
206
|
-
jdbcdriver:
|
207
|
-
one: JDBC driver
|
208
|
-
other: JDBC drivers
|
209
|
-
#
|
210
|
-
# These hints appear next to fields in SimpleForm forms
|
211
|
-
#
|
212
|
-
simple_form:
|
213
|
-
hints:
|
198
|
+
activity:
|
199
|
+
one: Activity
|
200
|
+
other: Activities
|
201
|
+
type:
|
202
|
+
autocomplete: Generate autocomplete index
|
203
|
+
click: Process click logs
|
204
|
+
optimize: Optimize index
|
214
205
|
collection:
|
215
|
-
|
216
|
-
|
217
|
-
|
206
|
+
one: Collection
|
207
|
+
other: Collections
|
208
|
+
settings:
|
209
|
+
de_duplication:
|
210
|
+
'off': 'Off'
|
211
|
+
overwrite: Overwrite
|
212
|
+
tag: Tag
|
213
|
+
one: Settings
|
214
|
+
other: Settings
|
218
215
|
datasource:
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
jdbc_datasource:
|
233
|
-
delta_sql_query: "$ in this query will be replaced by the last successful import time."
|
234
|
-
driver: "Database drivers may be uploaded on the Indexing -> JDBC Drivers page.
|
235
|
-
Drivers are collection specific.
|
236
|
-
JDBC4 drivers will appear in the selector automatically.
|
237
|
-
To use a JDBC3 driver, select \"Other\" and enter the Java class name of the driver."
|
238
|
-
url: "e.g. jdbc:mysql://hostname/database_name"
|
239
|
-
kfs_datasource:
|
240
|
-
lucidworkslogs_datasource:
|
241
|
-
s3_datasource:
|
242
|
-
url: "Please include protocol: s3://<hostname>/path/to/filesystem"
|
243
|
-
s3n_datasource:
|
244
|
-
url: "Please include protocol: s3n://<hostname>/path/to/filesystem"
|
245
|
-
sharepoint_datasource:
|
246
|
-
smb_datasource:
|
247
|
-
url: "Format: smb://<hostname or ip address>/<path to folder>/"
|
248
|
-
solrxml:
|
249
|
-
web_datasource:
|
250
|
-
include_paths: A list of regular expressions, one per line, e.g. http://example\.com/.*
|
251
|
-
will match everything within the site only.
|
252
|
-
url: e.g. http://cnn.com. Please include protocol (http/https).
|
253
|
-
|
216
|
+
one: Data source
|
217
|
+
other: Data sources
|
218
|
+
status:
|
219
|
+
crawl_state:
|
220
|
+
ABORTED: Aborted
|
221
|
+
ABORTING: Aborting
|
222
|
+
EXCEPTION: Exception
|
223
|
+
FINISHED: Finished
|
224
|
+
IDLE: Idle
|
225
|
+
RUNNING: Running
|
226
|
+
STOPPED: Stopped
|
227
|
+
STOPPING: Stopping
|
228
|
+
UNKNOWN: Unknown
|
254
229
|
field:
|
255
|
-
|
230
|
+
one: Field
|
231
|
+
other: Fields
|
232
|
+
indexing_options:
|
233
|
+
document_only: none
|
234
|
+
document_termfreq: term frequencies
|
235
|
+
document_termfreq_termpos: term frequencies and positions
|
236
|
+
fieldtype:
|
237
|
+
one: Field type
|
238
|
+
other: Field types
|
256
239
|
jdbcdriver:
|
257
|
-
|
258
|
-
|
259
|
-
mapping: ! 'Example: car, automobile, auto'
|
240
|
+
one: JDBC driver
|
241
|
+
other: JDBC drivers
|
data/lib/lucid_works/activity.rb
CHANGED
@@ -24,6 +24,7 @@ module LucidWorks
|
|
24
24
|
|
25
25
|
def frequency
|
26
26
|
case period
|
27
|
+
when 1.minute.seconds..59.minutes.seconds then 'every'
|
27
28
|
when 1.weeks.seconds then 'weekly'
|
28
29
|
when 1.days.seconds then 'daily'
|
29
30
|
when 1.hours.seconds then 'hourly'
|
@@ -37,6 +38,7 @@ module LucidWorks
|
|
37
38
|
#
|
38
39
|
def frequency=(frequency)
|
39
40
|
self.period = case frequency
|
41
|
+
when 'every' then period
|
40
42
|
when 'hourly' then 1.hours.seconds.to_i
|
41
43
|
when 'daily' then 1.days.seconds.to_i
|
42
44
|
when 'weekly' then 1.weeks.seconds.to_i
|
@@ -50,7 +52,6 @@ module LucidWorks
|
|
50
52
|
#
|
51
53
|
def next_start
|
52
54
|
return start_time if (now = Time.now) <= start_time
|
53
|
-
# require 'ruby-debug'; debugger
|
54
55
|
time_since_start = now - start_time
|
55
56
|
last_interval_num = (time_since_start / period).to_i
|
56
57
|
next_interval_num = if (time_since_start % period) == 0
|
@@ -104,8 +105,10 @@ module LucidWorks
|
|
104
105
|
self.frequency = all_attributes['frequency']
|
105
106
|
self.start_time =
|
106
107
|
case all_attributes['frequency']
|
108
|
+
when 'every'
|
109
|
+
self.period = all_attributes['period'].to_i
|
110
|
+
now.ceil(period)
|
107
111
|
when 'weekly'
|
108
|
-
# require 'ruby-debug'; debugger
|
109
112
|
start = now.beginning_of_week.advance(all_attributes['start'])
|
110
113
|
start < now ? start.advance(:weeks => 1) : start
|
111
114
|
when 'daily'
|
@@ -115,7 +118,7 @@ module LucidWorks
|
|
115
118
|
start = now.change(:min => 0).advance(all_attributes['start'])
|
116
119
|
start < now ? start.advance(:hours => 1) : start
|
117
120
|
when 'custom'
|
118
|
-
# don't change this
|
121
|
+
# don't change this schedule's start_time
|
119
122
|
else
|
120
123
|
puts "*** frequency: <#{all_attributes[:frequency]}>"
|
121
124
|
raise "unexpected frequency encountered"
|
@@ -170,8 +173,8 @@ module LucidWorks
|
|
170
173
|
end
|
171
174
|
end
|
172
175
|
|
173
|
-
def t_type
|
174
|
-
I18n.t
|
176
|
+
def t_type(i18n_options = {})
|
177
|
+
I18n.t type, {:scope => 'activemodel.models.collection.activity.type'}.merge(i18n_options)
|
175
178
|
end
|
176
179
|
|
177
180
|
def start
|
data/lib/lucid_works/base.rb
CHANGED
@@ -47,7 +47,7 @@ module LucidWorks
|
|
47
47
|
|
48
48
|
class << self
|
49
49
|
attr_accessor :collection_name # :nodoc:
|
50
|
-
|
50
|
+
attr_accessor :singleton
|
51
51
|
|
52
52
|
# The attributes for a model are ascertained in on of two ways.
|
53
53
|
# Without a schema, the attributes list is automatically generated when the the object is retrieved from the server.
|
@@ -127,11 +127,11 @@ module LucidWorks
|
|
127
127
|
|
128
128
|
url = case kind_of_find
|
129
129
|
when :all; collection_url(parent)
|
130
|
-
when :one;
|
131
|
-
when :singleton;
|
130
|
+
when :one; member_url(parent, id)
|
131
|
+
when :singleton; member_url(parent)
|
132
132
|
end
|
133
133
|
|
134
|
-
raw_response = ActiveSupport::Notifications.instrument("lucid_works
|
134
|
+
raw_response = ActiveSupport::Notifications.instrument("api.lucid_works") do |payload|
|
135
135
|
begin
|
136
136
|
payload[:method] = :get
|
137
137
|
payload[:uri] = url
|
@@ -178,7 +178,7 @@ module LucidWorks
|
|
178
178
|
|
179
179
|
if kind_of_find == :all && association_info[:retrieveable_en_masse]
|
180
180
|
all_targets_path = "#{collection_url(parent)}/all/#{target_name}"
|
181
|
-
raw_response = ActiveSupport::Notifications.instrument("lucid_works
|
181
|
+
raw_response = ActiveSupport::Notifications.instrument("api.lucid_works") do |payload|
|
182
182
|
begin
|
183
183
|
payload[:method] = :get
|
184
184
|
payload[:uri] = all_targets_path
|
@@ -265,6 +265,14 @@ module LucidWorks
|
|
265
265
|
"#{parent.uri}/#{collection_name}"
|
266
266
|
end
|
267
267
|
|
268
|
+
def member_url(parent, id = nil) # :nodoc:
|
269
|
+
if singleton
|
270
|
+
"#{parent.uri}/#{singleton_name}"
|
271
|
+
else
|
272
|
+
"#{parent.uri}/#{collection_name}/#{id}"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
268
276
|
def singleton_name # :nodoc:
|
269
277
|
name.underscore.gsub(/^.*\//, '')
|
270
278
|
end
|
@@ -291,13 +299,14 @@ module LucidWorks
|
|
291
299
|
@associations = {}
|
292
300
|
@persisted = options.delete(:persisted) || singleton? || false
|
293
301
|
@attributes = {}.with_indifferent_access
|
302
|
+
@singleton = false
|
294
303
|
load_attributes(options)
|
295
304
|
end
|
296
305
|
|
297
306
|
def save
|
298
307
|
return false unless valid?
|
299
|
-
|
300
|
-
ActiveSupport::Notifications.instrument("lucid_works
|
308
|
+
run_callbacks :save do
|
309
|
+
ActiveSupport::Notifications.instrument("api.lucid_works") do |payload|
|
301
310
|
method, uri = persisted? ? [:put, member_url] : [:post, collection_url]
|
302
311
|
data = encode
|
303
312
|
payload[:method] = method
|
@@ -324,15 +333,19 @@ module LucidWorks
|
|
324
333
|
end
|
325
334
|
end
|
326
335
|
|
327
|
-
def
|
336
|
+
def attributes=(attrs_and_values)
|
328
337
|
attrs_and_values.each do |attr,value|
|
329
338
|
self.send("#{attr}=", value)
|
330
339
|
end
|
340
|
+
end
|
341
|
+
|
342
|
+
def update_attributes(attrs_and_values)
|
343
|
+
self.attributes = attrs_and_values
|
331
344
|
save
|
332
345
|
end
|
333
346
|
|
334
347
|
def destroy(options={})
|
335
|
-
ActiveSupport::Notifications.instrument("lucid_works
|
348
|
+
ActiveSupport::Notifications.instrument("api.lucid_works") do |payload|
|
336
349
|
begin
|
337
350
|
payload[:method] = :delete
|
338
351
|
payload[:uri] = member_url
|
@@ -371,11 +384,7 @@ module LucidWorks
|
|
371
384
|
end
|
372
385
|
|
373
386
|
def member_url # :nodoc:
|
374
|
-
|
375
|
-
"#{parent.uri}/#{self.class.singleton_name}"
|
376
|
-
else
|
377
|
-
"#{parent.uri}/#{collection_name}/#{self.id}"
|
378
|
-
end
|
387
|
+
self.class.member_url(parent, self.id)
|
379
388
|
end
|
380
389
|
|
381
390
|
alias :uri :member_url
|
@@ -398,7 +407,7 @@ module LucidWorks
|
|
398
407
|
end
|
399
408
|
|
400
409
|
def singleton? # :nodoc:
|
401
|
-
self.class.singleton
|
410
|
+
!!self.class.singleton
|
402
411
|
end
|
403
412
|
|
404
413
|
def collection_name # :nodoc:
|
@@ -424,6 +433,8 @@ module LucidWorks
|
|
424
433
|
next
|
425
434
|
elsif self.class.respond_to?(:belongs_to_association_name) && attr.to_sym == self.class.belongs_to_association_name
|
426
435
|
next # Dont overwrite our connection to our parent
|
436
|
+
elsif schema.model.associations.keys.include?(attr.to_sym)
|
437
|
+
next # There is an association with the same name. The association takes precedence.
|
427
438
|
end
|
428
439
|
attribute = schema.find_or_create_attribute(attr)
|
429
440
|
send "#{attribute.name}=", value
|
@@ -439,7 +450,7 @@ module LucidWorks
|
|
439
450
|
data = JSON.parse(response) rescue nil
|
440
451
|
if data.is_a?(Hash) && data['errors']
|
441
452
|
data['errors'].each do |error|
|
442
|
-
key = error['key'].blank? ? 'base' : error['key']
|
453
|
+
key = error['key'].blank? ? 'base' : LucidWorks::Schema::Attribute.sanitize_name(error['key'])
|
443
454
|
# When core implements FOCUS-2262 start checking for error['code'] and lookup a translation.
|
444
455
|
self.errors.add(key, error['message'])
|
445
456
|
end
|