active_documentum 0.3.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/lib/active_documentum.rb +1 -0
- data/lib/active_documentum/access_control_client.rb +1 -0
- data/lib/active_documentum/base.rb +1 -0
- data/lib/active_documentum/docbase_config.rb +1 -0
- data/lib/active_documentum/logging.rb +21 -0
- data/lib/active_documentum/object_client.rb +1 -0
- data/lib/active_documentum/query_client.rb +1 -0
- data/lib/active_documentum/schema.rb +51 -0
- data/lib/active_documentum/schema_client.rb +1 -0
- data/lib/active_documentum/search_client.rb +1 -0
- data/lib/active_documentum/session.rb +1 -0
- data/lib/active_documentum/types/cfs_import_batch.rb +98 -0
- data/lib/active_documentum/types/cfs_import_document.rb +119 -0
- data/lib/active_documentum/types/dm_acl.rb +29 -0
- data/lib/active_documentum/types/dm_acs_config.rb +113 -0
- data/lib/active_documentum/types/dm_activity.rb +155 -0
- data/lib/active_documentum/types/dm_aggr_domain.rb +28 -0
- data/lib/active_documentum/types/dm_alias_set.rb +18 -0
- data/lib/active_documentum/types/dm_app_ref.rb +95 -0
- data/lib/active_documentum/types/dm_application.rb +108 -0
- data/lib/active_documentum/types/dm_assembly.rb +20 -0
- data/lib/active_documentum/types/dm_attachments_folder.rb +91 -0
- data/lib/active_documentum/types/dm_audittrail.rb +47 -0
- data/lib/active_documentum/types/dm_audittrail_acl.rb +58 -0
- data/lib/active_documentum/types/dm_audittrail_group.rb +61 -0
- data/lib/active_documentum/types/dm_blobstore.rb +28 -0
- data/lib/active_documentum/types/dm_bocs_config.rb +100 -0
- data/lib/active_documentum/types/dm_builtin_expr.rb +10 -0
- data/lib/active_documentum/types/dm_business_pro.rb +93 -0
- data/lib/active_documentum/types/dm_ca_store.rb +33 -0
- data/lib/active_documentum/types/dm_cabinet.rb +92 -0
- data/lib/active_documentum/types/dm_cache_config.rb +96 -0
- data/lib/active_documentum/types/dm_category.rb +106 -0
- data/lib/active_documentum/types/dm_category_assign.rb +24 -0
- data/lib/active_documentum/types/dm_category_class.rb +99 -0
- data/lib/active_documentum/types/dm_ci_config.rb +108 -0
- data/lib/active_documentum/types/dm_client_registration.rb +93 -0
- data/lib/active_documentum/types/dm_client_rights.rb +96 -0
- data/lib/active_documentum/types/dm_component.rb +93 -0
- data/lib/active_documentum/types/dm_cond_expr.rb +21 -0
- data/lib/active_documentum/types/dm_cond_id_expr.rb +23 -0
- data/lib/active_documentum/types/dm_cont_transfer_config.rb +93 -0
- data/lib/active_documentum/types/dm_cryptographic_key.rb +93 -0
- data/lib/active_documentum/types/dm_dd_info.rb +44 -0
- data/lib/active_documentum/types/dm_decision.rb +95 -0
- data/lib/active_documentum/types/dm_display_config.rb +11 -0
- data/lib/active_documentum/types/dm_distributedstore.rb +29 -0
- data/lib/active_documentum/types/dm_dms_config.rb +94 -0
- data/lib/active_documentum/types/dm_docbase_config.rb +132 -0
- data/lib/active_documentum/types/dm_docbaseid_map.rb +9 -0
- data/lib/active_documentum/types/dm_docset.rb +94 -0
- data/lib/active_documentum/types/dm_docset_run.rb +100 -0
- data/lib/active_documentum/types/dm_document.rb +89 -0
- data/lib/active_documentum/types/dm_domain.rb +16 -0
- data/lib/active_documentum/types/dm_dump_record.rb +21 -0
- data/lib/active_documentum/types/dm_email_message.rb +96 -0
- data/lib/active_documentum/types/dm_esign_template.rb +94 -0
- data/lib/active_documentum/types/dm_expression.rb +9 -0
- data/lib/active_documentum/types/dm_extern_file.rb +38 -0
- data/lib/active_documentum/types/dm_extern_free.rb +34 -0
- data/lib/active_documentum/types/dm_extern_store.rb +34 -0
- data/lib/active_documentum/types/dm_extern_url.rb +34 -0
- data/lib/active_documentum/types/dm_federation.rb +96 -0
- data/lib/active_documentum/types/dm_filestore.rb +29 -0
- data/lib/active_documentum/types/dm_folder.rb +91 -0
- data/lib/active_documentum/types/dm_foreign_key.rb +20 -0
- data/lib/active_documentum/types/dm_format.rb +26 -0
- data/lib/active_documentum/types/dm_format_preferences.rb +89 -0
- data/lib/active_documentum/types/dm_ftengine_config.rb +91 -0
- data/lib/active_documentum/types/dm_ftindex_agent_config.rb +108 -0
- data/lib/active_documentum/types/dm_fulltext_index.rb +14 -0
- data/lib/active_documentum/types/dm_func_expr.rb +20 -0
- data/lib/active_documentum/types/dm_group.rb +57 -0
- data/lib/active_documentum/types/dm_java.rb +92 -0
- data/lib/active_documentum/types/dm_jms_config.rb +104 -0
- data/lib/active_documentum/types/dm_job.rb +114 -0
- data/lib/active_documentum/types/dm_job_request.rb +95 -0
- data/lib/active_documentum/types/dm_job_sequence.rb +95 -0
- data/lib/active_documentum/types/dm_key.rb +9 -0
- data/lib/active_documentum/types/dm_ldap_config.rb +123 -0
- data/lib/active_documentum/types/dm_linkedstore.rb +28 -0
- data/lib/active_documentum/types/dm_literal_expr.rb +9 -0
- data/lib/active_documentum/types/dm_load_record.rb +16 -0
- data/lib/active_documentum/types/dm_location.rb +94 -0
- data/lib/active_documentum/types/dm_locator.rb +90 -0
- data/lib/active_documentum/types/dm_media_profile.rb +93 -0
- data/lib/active_documentum/types/dm_menu_system.rb +89 -0
- data/lib/active_documentum/types/dm_message_address.rb +14 -0
- data/lib/active_documentum/types/dm_message_archive.rb +112 -0
- data/lib/active_documentum/types/dm_message_attachment.rb +10 -0
- data/lib/active_documentum/types/dm_message_container.rb +97 -0
- data/lib/active_documentum/types/dm_message_route_user_data.rb +9 -0
- data/lib/active_documentum/types/dm_message_user_data.rb +9 -0
- data/lib/active_documentum/types/dm_method.rb +104 -0
- data/lib/active_documentum/types/dm_migrate_rule.rb +152 -0
- data/lib/active_documentum/types/dm_mount_point.rb +95 -0
- data/lib/active_documentum/types/dm_network_location_map.rb +95 -0
- data/lib/active_documentum/types/dm_nls_dd_info.rb +21 -0
- data/lib/active_documentum/types/dm_note.rb +89 -0
- data/lib/active_documentum/types/dm_opticalstore.rb +30 -0
- data/lib/active_documentum/types/dm_outputdevice.rb +96 -0
- data/lib/active_documentum/types/dm_plugin.rb +93 -0
- data/lib/active_documentum/types/dm_policy.rb +122 -0
- data/lib/active_documentum/types/dm_procedure.rb +90 -0
- data/lib/active_documentum/types/dm_process.rb +124 -0
- data/lib/active_documentum/types/dm_public_key_certificate.rb +93 -0
- data/lib/active_documentum/types/dm_qual_comp.rb +96 -0
- data/lib/active_documentum/types/dm_query.rb +89 -0
- data/lib/active_documentum/types/dm_reference.rb +30 -0
- data/lib/active_documentum/types/dm_registered.rb +100 -0
- data/lib/active_documentum/types/dm_relation.rb +15 -0
- data/lib/active_documentum/types/dm_relation_ssa_policy.rb +17 -0
- data/lib/active_documentum/types/dm_relation_type.rb +18 -0
- data/lib/active_documentum/types/dm_retainer.rb +101 -0
- data/lib/active_documentum/types/dm_router.rb +130 -0
- data/lib/active_documentum/types/dm_scope_config.rb +9 -0
- data/lib/active_documentum/types/dm_script.rb +89 -0
- data/lib/active_documentum/types/dm_server_config.rb +159 -0
- data/lib/active_documentum/types/dm_shmeconfig.rb +7 -0
- data/lib/active_documentum/types/dm_smart_list.rb +93 -0
- data/lib/active_documentum/types/dm_ssa_policy.rb +90 -0
- data/lib/active_documentum/types/dm_staged.rb +91 -0
- data/lib/active_documentum/types/dm_state_extension.rb +16 -0
- data/lib/active_documentum/types/dm_state_type.rb +7 -0
- data/lib/active_documentum/types/dm_store.rb +26 -0
- data/lib/active_documentum/types/dm_sync_list_relation.rb +16 -0
- data/lib/active_documentum/types/dm_sysobject.rb +89 -0
- data/lib/active_documentum/types/dm_sysprocess_config.rb +104 -0
- data/lib/active_documentum/types/dm_taxonomy.rb +107 -0
- data/lib/active_documentum/types/dm_type.rb +24 -0
- data/lib/active_documentum/types/dm_user.rb +45 -0
- data/lib/active_documentum/types/dm_validation_descriptor.rb +91 -0
- data/lib/active_documentum/types/dm_value_assist.rb +11 -0
- data/lib/active_documentum/types/dm_value_func.rb +13 -0
- data/lib/active_documentum/types/dm_value_list.rb +12 -0
- data/lib/active_documentum/types/dm_value_query.rb +14 -0
- data/lib/active_documentum/types/dm_webc_config.rb +114 -0
- data/lib/active_documentum/types/dm_webc_target.rb +112 -0
- data/lib/active_documentum/types/dm_workflow.rb +39 -0
- data/lib/active_documentum/types/dm_xml_application.rb +96 -0
- data/lib/active_documentum/types/dm_xml_config.rb +90 -0
- data/lib/active_documentum/types/dm_xml_custom_code.rb +92 -0
- data/lib/active_documentum/types/dm_xml_style_sheet.rb +90 -0
- data/lib/active_documentum/types/dm_xml_zone.rb +91 -0
- data/lib/active_documentum/types/dmc_act_group_instance.rb +16 -0
- data/lib/active_documentum/types/dmc_aspect_relation.rb +8 -0
- data/lib/active_documentum/types/dmc_aspect_type.rb +111 -0
- data/lib/active_documentum/types/dmc_class.rb +92 -0
- data/lib/active_documentum/types/dmc_comment.rb +97 -0
- data/lib/active_documentum/types/dmc_completed_workflow.rb +21 -0
- data/lib/active_documentum/types/dmc_completed_workitem.rb +26 -0
- data/lib/active_documentum/types/dmc_composite_predicate.rb +7 -0
- data/lib/active_documentum/types/dmc_config_scope_relation.rb +17 -0
- data/lib/active_documentum/types/dmc_constraint_set.rb +92 -0
- data/lib/active_documentum/types/dmc_dar.rb +92 -0
- data/lib/active_documentum/types/dmc_jar.rb +91 -0
- data/lib/active_documentum/types/dmc_java_library.rb +92 -0
- data/lib/active_documentum/types/dmc_metamodel.rb +89 -0
- data/lib/active_documentum/types/dmc_module.rb +103 -0
- data/lib/active_documentum/types/dmc_module_config.rb +10 -0
- data/lib/active_documentum/types/dmc_notepage.rb +90 -0
- data/lib/active_documentum/types/dmc_preset_info.rb +19 -0
- data/lib/active_documentum/types/dmc_preset_package.rb +93 -0
- data/lib/active_documentum/types/dmc_process_correlation_set.rb +17 -0
- data/lib/active_documentum/types/dmc_process_parameter.rb +99 -0
- data/lib/active_documentum/types/dmc_readcomment.rb +8 -0
- data/lib/active_documentum/types/dmc_relationship_def.rb +104 -0
- data/lib/active_documentum/types/dmc_richtext.rb +92 -0
- data/lib/active_documentum/types/dmc_room.rb +100 -0
- data/lib/active_documentum/types/dmc_routecase_condition.rb +23 -0
- data/lib/active_documentum/types/dmc_tcf_activity.rb +91 -0
- data/lib/active_documentum/types/dmc_tcf_activity_template.rb +91 -0
- data/lib/active_documentum/types/dmc_topic.rb +94 -0
- data/lib/active_documentum/types/dmc_transition_condition.rb +20 -0
- data/lib/active_documentum/types/dmc_validation_module.rb +106 -0
- data/lib/active_documentum/types/dmc_validation_relation.rb +17 -0
- data/lib/active_documentum/types/dmc_wf_package_schema.rb +16 -0
- data/lib/active_documentum/types/dmc_wf_package_skill.rb +17 -0
- data/lib/active_documentum/types/dmc_wf_package_type_info.rb +93 -0
- data/lib/active_documentum/types/dmc_wfsd_element.rb +96 -0
- data/lib/active_documentum/types/dmc_wfsd_element_boolean.rb +97 -0
- data/lib/active_documentum/types/dmc_wfsd_element_date.rb +97 -0
- data/lib/active_documentum/types/dmc_wfsd_element_double.rb +97 -0
- data/lib/active_documentum/types/dmc_wfsd_element_integer.rb +97 -0
- data/lib/active_documentum/types/dmc_wfsd_element_parent.rb +92 -0
- data/lib/active_documentum/types/dmc_wfsd_element_string.rb +97 -0
- data/lib/active_documentum/types/dmc_wfsd_type_info.rb +106 -0
- data/lib/active_documentum/types/dmc_wfsdrp_boolean.rb +16 -0
- data/lib/active_documentum/types/dmc_wfsdrp_date.rb +16 -0
- data/lib/active_documentum/types/dmc_wfsdrp_double.rb +16 -0
- data/lib/active_documentum/types/dmc_wfsdrp_integer.rb +16 -0
- data/lib/active_documentum/types/dmc_wfsdrp_parent.rb +15 -0
- data/lib/active_documentum/types/dmc_wfsdrp_string.rb +16 -0
- data/lib/active_documentum/types/dmc_workqueue.rb +9 -0
- data/lib/active_documentum/types/dmc_workqueue_category.rb +91 -0
- data/lib/active_documentum/types/dmc_workqueue_doc_profile.rb +9 -0
- data/lib/active_documentum/types/dmc_workqueue_policy.rb +16 -0
- data/lib/active_documentum/types/dmc_workqueue_user_profile.rb +10 -0
- data/lib/active_documentum/types/dmc_wpr_parent.rb +16 -0
- data/lib/active_documentum/types/dmc_wq_skill_info.rb +14 -0
- data/lib/active_documentum/types/dmc_wq_task_skill.rb +10 -0
- data/lib/active_documentum/types/dmc_wq_user_skill.rb +10 -0
- data/lib/active_documentum/types/dmi_audittrail_attrs.rb +8 -0
- data/lib/active_documentum/types/dmi_change_record.rb +13 -0
- data/lib/active_documentum/types/dmi_dd_attr_info.rb +116 -0
- data/lib/active_documentum/types/dmi_dd_common_info.rb +57 -0
- data/lib/active_documentum/types/dmi_dd_type_info.rb +87 -0
- data/lib/active_documentum/types/dmi_dist_comp_record.rb +8 -0
- data/lib/active_documentum/types/dmi_dump_object_record.rb +9 -0
- data/lib/active_documentum/types/dmi_expr_code.rb +91 -0
- data/lib/active_documentum/types/dmi_index.rb +15 -0
- data/lib/active_documentum/types/dmi_linkrecord.rb +12 -0
- data/lib/active_documentum/types/dmi_load_object_record.rb +15 -0
- data/lib/active_documentum/types/dmi_otherfile.rb +9 -0
- data/lib/active_documentum/types/dmi_package.rb +22 -0
- data/lib/active_documentum/types/dmi_queue_item.rb +47 -0
- data/lib/active_documentum/types/dmi_recovery.rb +10 -0
- data/lib/active_documentum/types/dmi_registry.rb +21 -0
- data/lib/active_documentum/types/dmi_replica_record.rb +13 -0
- data/lib/active_documentum/types/dmi_sequence.rb +11 -0
- data/lib/active_documentum/types/dmi_session.rb +12 -0
- data/lib/active_documentum/types/dmi_subcontent.rb +9 -0
- data/lib/active_documentum/types/dmi_transactionlog.rb +8 -0
- data/lib/active_documentum/types/dmi_type_info.rb +22 -0
- data/lib/active_documentum/types/dmi_vstamp.rb +6 -0
- data/lib/active_documentum/types/dmi_wf_attachment.rb +11 -0
- data/lib/active_documentum/types/dmi_wf_timer.rb +17 -0
- data/lib/active_documentum/types/dmi_workitem.rb +35 -0
- data/lib/active_documentum/types/dmr_containment.rb +15 -0
- data/lib/active_documentum/types/dmr_content.rb +58 -0
- data/lib/active_documentum/typescfs_import_batch.rb +93 -0
- data/lib/support.rb +13 -0
- data/test/active_documentum/access_control_client_test.rb +15 -0
- data/test/active_documentum/docbase_config_test.rb +41 -0
- data/test/active_documentum/object_client_test.rb +11 -0
- data/test/active_documentum/query_client_test.rb +9 -0
- data/test/active_documentum/schema_client_test.rb +27 -0
- data/test/active_documentum/search_client_test.rb +9 -0
- data/test/active_documentum/types/dm_group_test.rb +151 -0
- data/test/active_documentum/types/dm_user_test.rb +106 -0
- data/test/active_documentum_test.rb +9 -0
- data/test/test_helper.rb +8 -0
- metadata +298 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 'Luke
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
= Active Documentum
|
2
|
+
|
3
|
+
Active Documentum is a gem designed to enable interactions with Documentum. Particularly using DQL (Documentum Query Language) to be more Active Record like. It was written quite some time ago to help me do administrative tasks.
|
4
|
+
|
5
|
+
== Copyright
|
6
|
+
|
7
|
+
Copyright (c) 2009 'Luke Chadwick'. See LICENSE for details.
|
@@ -0,0 +1 @@
|
|
1
|
+
#$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
require entry
|
1
3
|
autoload :DocbaseConfig, 'active_documentum/docbase_config'
|
2
4
|
autoload :Session, 'active_documentum/session'
|
3
5
|
autoload :Base, 'active_documentum/base'
|
4
6
|
autoload :Schema, 'active_documentum/schema'
|
5
7
|
|
6
8
|
autoload :QueryClient, 'active_documentum/query_client'
|
7
9
|
autoload :SchemaClient, 'active_documentum/schema_client'
|
8
10
|
autoload :ObjectClient, 'active_documentum/object_client'
|
9
11
|
autoload :SearchClient, 'active_documentum/search_client'
|
10
12
|
autoload :AccessControlClient, 'active_documentum/access_control_client'
|
11
13
|
ActiveDocumentum::DocbaseConfig.load
|
12
14
|
Dir[File.join(File.dirname(__FILE__),'active_documentum/types')+'/*'].each do |file_name|
|
13
15
|
autoload camelize(File.basename(file_name,'.rb')).intern, file_name
|
14
16
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
module ActiveDocumentum
|
2
|
class Base
|
1
3
|
@@table_name = nil
|
2
4
|
attr_accessor :attributes
|
3
5
|
class << self # Class methods
|
4
6
|
|
5
7
|
def establish_connection(attributes = {})
|
6
8
|
DocbaseConfig.url = attributes[:url] unless attributes[:url].nil?
|
7
9
|
DocbaseConfig.docbase = attributes[:docbase] unless attributes[:docbase].nil?
|
8
10
|
DocbaseConfig.username = attributes[:username] unless attributes[:username].nil?
|
9
11
|
DocbaseConfig.password = attributes[:password] unless attributes[:password].nil?
|
10
12
|
nil
|
11
13
|
end
|
12
14
|
|
13
15
|
def find(*args)
|
14
16
|
sym = args.first
|
15
17
|
options = {}
|
16
18
|
options = args.last if args.size > 1
|
17
19
|
#validate_find_options(options)
|
18
20
|
#set_readonly_option!(options)
|
19
21
|
case sym
|
20
22
|
when :first then find_initial(options)
|
21
23
|
when :all then find_every(options)
|
22
24
|
else find_from_ids(args, options)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
# A convenience wrapper for <tt>find(:first, *args)</tt>. You can pass in all the
|
27
29
|
# same arguments to this method as you can to <tt>find(:first)</tt>.
|
28
30
|
def first(*args)
|
29
31
|
find(:first, *args)
|
30
32
|
end
|
31
33
|
# A convenience wrapper for <tt>find(:last, *args)</tt>. You can pass in all the
|
32
34
|
# same arguments to this method as you can to <tt>find(:last)</tt>.
|
33
35
|
def last(*args)
|
34
36
|
find(:last, *args)
|
35
37
|
end
|
36
38
|
# This is an alias for find(:all). You can pass in all the same arguments to this method as you can
|
37
39
|
# to find(:all)
|
38
40
|
def all(*args)
|
39
41
|
find(:all, *args)
|
40
42
|
end
|
41
43
|
|
42
44
|
private
|
43
45
|
def find_initial(options)
|
44
46
|
options[:limit] = 1
|
45
47
|
result = find_every(options)
|
46
48
|
result.first if result.size > 0
|
47
49
|
end
|
48
50
|
def find_every(options)
|
49
51
|
columns = (options[:columns] || "*")
|
50
52
|
conditions = options[:conditions]
|
51
53
|
order = options[:order]
|
52
54
|
offset = (options[:offset] || 0).to_i
|
53
55
|
page_size = (options[:page_size] || 500).to_i
|
54
56
|
limit = options[:limit]
|
55
57
|
query = "SELECT #{columns} FROM #{self.table_name}"
|
56
58
|
where = ""
|
57
59
|
unless conditions.nil?
|
58
60
|
if conditions.is_a? Hash
|
59
61
|
where = " WHERE "
|
60
62
|
conditions.keys.each do |key|
|
61
63
|
where += "#{key.to_s} = '#{conditions[key]}' AND "
|
62
64
|
end
|
63
65
|
where.chomp!(" AND ")
|
64
66
|
elsif conditions.is_a? String
|
65
67
|
where = " WHERE " + conditions
|
66
68
|
end
|
67
69
|
end
|
68
70
|
query += where
|
69
71
|
query += " ORDER BY " + order unless order.nil?
|
70
72
|
@@connection ||= QueryClient.new
|
71
73
|
total_results = @@connection.result_count(query).to_i
|
72
74
|
unless limit.nil?
|
73
75
|
total_results = limit.to_i
|
74
76
|
page_size = limit.to_i if page_size.to_i > limit.to_i
|
75
77
|
end
|
76
78
|
results = []
|
77
79
|
while(offset < total_results)
|
78
80
|
execute(query, :page_size => page_size, :start_index => offset).each do |row|
|
79
81
|
a = self.new(row)
|
80
82
|
results << a
|
81
83
|
end
|
82
84
|
offset += page_size
|
83
85
|
end
|
84
86
|
return results
|
85
87
|
end
|
86
88
|
def find_from_ids(ids, options)
|
87
89
|
expects_array = ids.first.kind_of?(Array)
|
88
90
|
return ids.first if expects_array && ids.first.empty?
|
89
91
|
ids = ids.flatten.compact.uniq
|
90
92
|
case ids.size
|
91
93
|
when 0
|
92
94
|
raise StandardError, "Couldn't find #{name} without an ID"
|
93
95
|
when 1
|
94
96
|
result = find_one(ids.first, options)
|
95
97
|
expects_array ? [ result ] : result
|
96
98
|
else
|
97
99
|
find_some(ids, options)
|
98
100
|
end
|
99
101
|
end
|
100
102
|
def find_one(id, options)
|
101
103
|
conditions = " AND (#{options[:conditions]})" if options[:conditions]
|
102
104
|
options[:conditions] = "r_object_id = '#{id}'#{conditions}"
|
103
105
|
# Use find_every(options).first since the primary key condition
|
104
106
|
# already ensures we have a single record. Using find_initial adds
|
105
107
|
# a superfluous :limit => 1.
|
106
108
|
if result = find_every(options).first
|
107
109
|
result
|
108
110
|
else
|
109
111
|
raise StandardError, "Couldn't find #{name} with ID=#{id}#{conditions}"
|
110
112
|
end
|
111
113
|
end
|
112
114
|
def find_some(ids, options)
|
113
115
|
conditions = " AND (#{options[:conditions]})" if options[:conditions]
|
114
116
|
ids_list = ids.map { |id| "'#{id}'" }.join(',')
|
115
117
|
options[:conditions] = "r_object_id IN (#{ids_list})#{conditions}"
|
116
118
|
result = find_every(options)
|
117
119
|
# Determine expected size from limit and offset, not just ids.size.
|
118
120
|
expected_size =
|
119
121
|
if options[:limit] && ids.size > options[:limit]
|
120
122
|
options[:limit]
|
121
123
|
else
|
122
124
|
ids.size
|
123
125
|
end
|
124
126
|
# 11 ids with limit 3, offset 9 should give 2 results.
|
125
127
|
if options[:offset] && (ids.size - options[:offset] < expected_size)
|
126
128
|
expected_size = ids.size - options[:offset]
|
127
129
|
end
|
128
130
|
if result.size == expected_size
|
129
131
|
result
|
130
132
|
else
|
131
133
|
raise StandardError, "Couldn't find all IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})"
|
132
134
|
end
|
133
135
|
end
|
134
136
|
|
135
137
|
# Drying up executes to a single QueryClient instance
|
136
138
|
def execute(query, options = {})
|
137
139
|
@@connection ||= QueryClient.new
|
138
140
|
$log.debug query
|
139
141
|
result = @@connection.execute(query, options)
|
140
142
|
result
|
141
143
|
end
|
142
144
|
|
143
145
|
end
|
144
146
|
model = self.new(attributes)
|
145
147
|
result = model.save
|
146
148
|
def delete
|
147
149
|
query = "DELETE #{self.class.table_name} OBJECT"
|
148
150
|
query += " WHERE r_object_id = '#{self.r_object_id}'"
|
149
151
|
result = execute(query).first
|
150
152
|
end
|
151
153
|
|
152
154
|
@table_name = value
|
153
155
|
return @table_name unless @table_name.nil?
|
154
156
|
return self.name.gsub(/([A-Z])/, '_\1').downcase.reverse.chop.reverse
|
155
157
|
# Method missing in this case returns an existing attribute if it exists
|
156
158
|
# and can assign attributes, but only if they already exist. Will need
|
157
159
|
# some work to round it out eventually.
|
158
160
|
def method_missing(meth,*args)
|
159
161
|
unless meth.to_s.include?('=') #TODO dodgy
|
160
162
|
super if @attributes_cache[meth.to_s].nil?
|
161
163
|
return @attributes_cache[meth.to_s]
|
162
164
|
end
|
163
165
|
key = meth.to_s.gsub("=", "")
|
164
166
|
@attributes_cache[key] = args.first
|
165
167
|
return @attributes_cache[key]
|
166
168
|
end
|
167
169
|
"<#{self.class.to_s} @attributes=#{@attributes_cache.inspect}/>"
|
168
170
|
private
|
169
171
|
#raise ReadOnlyRecord if readonly?
|
170
172
|
new_record? ? create_record : update
|
171
173
|
end
|
172
174
|
# Updates the associated record with values matching those of the instance attributes.
|
173
175
|
# Returns the number of affected rows.
|
174
176
|
def update(attribute_names = @attributes.keys)
|
175
177
|
query = "UPDATE #{self.class.table_name} OBJECT"
|
176
178
|
@attributes_cache.keys.each do |key|
|
177
179
|
query += " SET #{key.to_s} = '#{@attributes_cache[key]}'"
|
178
180
|
end
|
179
181
|
query += " WHERE r_object_id = '#{self.r_object_id}'"
|
180
182
|
result = execute(query).first
|
181
183
|
end
|
182
184
|
# Creates a record with values matching those of the instance attributes
|
183
185
|
# and returns its id.
|
184
186
|
def create_record
|
185
187
|
query = "CREATE #{self.class.table_name} OBJECT"
|
186
188
|
@attributes_cache.keys.each do |key|
|
187
189
|
query += " SET #{key.to_s} = '#{@attributes_cache[key]}'"
|
188
190
|
end
|
189
191
|
result = execute(query).first
|
190
192
|
@new_record = false
|
191
193
|
result
|
192
194
|
end
|
193
195
|
|
194
196
|
# Drying up executes to a single QueryClient instance
|
195
197
|
def execute(query, options = {})
|
196
198
|
@@connection ||= QueryClient.new
|
197
199
|
$log.debug query
|
198
200
|
result = @@connection.execute(query, options)
|
199
201
|
result
|
200
202
|
end
|
201
203
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
module ActiveDocumentum
|
2
|
class DocbaseConfig
|
1
3
|
@@config = {}
|
2
4
|
def self.docbase
|
3
5
|
load if @@config.empty?
|
4
6
|
@@config[$environment]["docbase"]
|
5
7
|
end
|
6
8
|
def self.docbase=(value)
|
7
9
|
@@config[$environment] ||= {}
|
8
10
|
@@config[$environment]["docbase"] = value
|
9
11
|
end
|
10
12
|
def self.username
|
11
13
|
load if @@config.empty? or @@config.nil?
|
12
14
|
@@config[$environment]["username"]
|
13
15
|
end
|
14
16
|
def self.username=(value)
|
15
17
|
@@config[$environment] ||= {}
|
16
18
|
@@config[$environment]["username"] = value
|
17
19
|
end
|
18
20
|
def self.password
|
19
21
|
load if @@config.empty? or @@config.nil?
|
20
22
|
@@config[$environment]["password"]
|
21
23
|
end
|
22
24
|
def self.password=(value)
|
23
25
|
@@config[$environment] ||= {}
|
24
26
|
@@config[$environment]["password"] = value
|
25
27
|
end
|
26
28
|
def self.url
|
27
29
|
load if @@config.empty? or @@config.nil?
|
28
30
|
@@config[$environment]["url"]
|
29
31
|
end
|
30
32
|
def self.url=(value)
|
31
33
|
@@config[$environment] ||= {}
|
32
34
|
@@config[$environment]["url"] = value
|
33
35
|
end
|
34
36
|
def self.load
|
35
37
|
$log.debug "Loading config"
|
36
38
|
@@config.merge!(YAML.load(File.open('config/environment.yml')))
|
37
39
|
end
|
38
40
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Author:: Luke Chadwick (mailto:luke.a.chadwick@gmail.com)
|
2
|
+
# Copyright:: Copyright (c) 2010 Luke Chadwick
|
3
|
+
# License:: Distributes under the same terms as Ruby
|
4
|
+
#
|
5
|
+
# The class handles logging for ActiveDocumentum
|
6
|
+
module ActiveDocumentum
|
7
|
+
class Logging
|
8
|
+
def initialize()
|
9
|
+
include Log4r
|
10
|
+
$log = Logger.new($environment)
|
11
|
+
#$log.level = Log4r::INFO
|
12
|
+
format = PatternFormatter.new(:pattern => "[%l] %d :: %m")
|
13
|
+
stdout_outputter = Outputter.stdout
|
14
|
+
stdout_outputter.formatter = format
|
15
|
+
FileUtils.mkdir_p('log')
|
16
|
+
file = FileOutputter.new('fileOutputter', :filename => "log/#{$environment}.log",:trunc => false)
|
17
|
+
file.formatter = format
|
18
|
+
$log.outputters = stdout_outputter, file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
module ActiveDocumentum
|
2
|
def get(object_id)
|
1
3
|
objIdentity = ObjectIdentity.new(ObjectId.new(object_id), ActiveDocumentum::DocbaseConfig.docbase)
|
2
4
|
objectIdSet = ObjectIdentitySet.new()
|
3
5
|
objectIdSet.addIdentity(objIdentity)
|
4
6
|
operationOptions = OperationOptions.new()
|
5
7
|
|
6
8
|
propertyProfile = PropertyProfile.new(PropertyFilterMode.const_get("ALL"))
|
7
9
|
contentProfile = ContentProfile.new
|
8
10
|
contentTransferProfile = ContentTransferProfile.new
|
9
11
|
|
10
12
|
permissionProfile = PermissionProfile.new
|
11
13
|
permissionProfile.setPermissionTypeFilter(PermissionTypeFilter.const_get("ANY"))
|
12
14
|
operationOptions.setPermissionProfile(permissionProfile)
|
13
15
|
contentTransferProfile.setTransferMode(ContentTransferMode.const_get("MTOM"))
|
14
16
|
contentProfile.setFormatFilter(FormatFilter.const_get("ANY"))
|
15
17
|
operationOptions.setContentTransferProfile(contentTransferProfile)
|
16
18
|
operationOptions.setPropertyProfile(propertyProfile)
|
17
19
|
operationOptions.setContentProfile(contentProfile)
|
18
20
|
operationOptions.setProfile(contentProfile);
|
19
21
|
|
20
22
|
dataPackage = @service.get(objectIdSet, operationOptions)
|
21
23
|
return dataPackage.getDataObjects().get(0)
|
22
24
|
end
|
23
25
|
|
24
26
|
# Not finished!
|
25
27
|
def create(object_type, name, folder_path, properties = {})
|
26
28
|
# create a contentless document to link into folder
|
27
29
|
#String repositoryName = defaultRepositoryName;
|
28
30
|
obj_identity = ObjectIdentity.new(ActiveDocumentum::DocbaseConfig.docbase)
|
29
31
|
dataObject = DataObject.new(obj_identity, object_type)
|
30
32
|
dataObject.getProperties().set("object_name", name)
|
31
33
|
# properties.each_pair do |key, value|
|
32
34
|
# dataObject.getProperties().set(key, value)
|
33
35
|
# end
|
34
36
|
# add the folder to link to as a ReferenceRelationship
|
35
37
|
object_path = ObjectPath.new(folder_path)
|
36
38
|
folder_identity = ObjectIdentity.new(object_path,
|
37
39
|
ActiveDocumentum::DocbaseConfig.docbase)
|
38
40
|
folderRelationship = ReferenceRelationship.new()
|
39
41
|
folderRelationship.setName(Relationship.const_get("RELATIONSHIP_FOLDER"))
|
40
42
|
folderRelationship.setTarget(folder_identity)
|
41
43
|
folderRelationship.setTargetRole(Relationship.const_get("ROLE_PARENT"))
|
42
44
|
dataObject.getRelationships().add(folderRelationship)
|
43
45
|
# create a new document linked into parent folder
|
44
46
|
operationOptions = nil
|
45
47
|
dataPackage = DataPackage.new(dataObject)
|
46
48
|
result = @service.create(dataPackage, operationOptions)
|
47
49
|
return result
|
48
50
|
end
|
49
51
|
|
50
52
|
# Not finished!
|
51
53
|
# Expected format of an objects entry is {:object_type => "", :name => "", :path => "", :properties => {}}
|
52
54
|
def create_many(objects = [])
|
53
55
|
return if objects.empty?
|
54
56
|
dataPackage = DataPackage.new
|
55
57
|
obj_identity = ObjectIdentity.new(ActiveDocumentum::DocbaseConfig.docbase)
|
56
58
|
objects.each do |object|
|
57
59
|
dataObject = DataObject.new(obj_identity, object[:object_type])
|
58
60
|
dataObject.getProperties().set("object_name", object[:name])
|
59
61
|
# add the folder to link to as a ReferenceRelationship
|
60
62
|
object_path = ObjectPath.new(object[:path])
|
61
63
|
folder_identity = ObjectIdentity.new(object_path,
|
62
64
|
ActiveDocumentum::DocbaseConfig.docbase)
|
63
65
|
folderRelationship = ReferenceRelationship.new()
|
64
66
|
folderRelationship.setName(Relationship.const_get("RELATIONSHIP_FOLDER"))
|
65
67
|
folderRelationship.setTarget(folder_identity)
|
66
68
|
folderRelationship.setTargetRole(Relationship.const_get("ROLE_PARENT"))
|
67
69
|
unless object[:content].nil?
|
68
70
|
dataObject.getProperties().set("a_content_type", "crtext")
|
69
71
|
dataObject.getContents().add(FileContent.new("C:\\dummy_doc.txt", "crtext"))
|
70
72
|
end
|
71
73
|
dataObject.getRelationships().add(folderRelationship)
|
72
74
|
dataPackage.addDataObject(dataObject)
|
73
75
|
end
|
74
76
|
# create a new document linked into parent folder
|
75
77
|
operationOptions = nil
|
76
78
|
|
77
79
|
result = @service.create(dataPackage, operationOptions)
|
78
80
|
return result
|
79
81
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Author:: Luke Chadwick (mailto:luke.a.chadwick@gmail.com)
|
2
|
+
# Copyright:: Copyright (c) 2010 Luke Chadwick
|
3
|
+
# License:: Distributes under the same terms as Ruby
|
4
|
+
#
|
5
|
+
# This class handles high level access to Documentum schemas. It supports caching
|
6
|
+
# of the schemas to the 'tmp/types' directory
|
7
|
+
module ActiveDocumentum
|
8
|
+
class Schema
|
9
|
+
include Support
|
10
|
+
|
11
|
+
@@sc = nil
|
12
|
+
@@schema = nil
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@@sc ||= ActiveDocumentum::SchemaClient.new
|
16
|
+
@@schema ||= @@sc.schema_info
|
17
|
+
@base_dir = "lib/active_documentum/types/" #TODO find better way of doing this
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_type(type_name)
|
21
|
+
file_name = @base_dir + type_name + '.rb'
|
22
|
+
unless File.exists?(file_name)
|
23
|
+
type = @@sc.type_info(type_name)
|
24
|
+
class_name = camelize(type_name)
|
25
|
+
parent_name = camelize(type[:parent_name]) unless type[:parent_name].empty?
|
26
|
+
parent_name ||= "ActiveDocumentum::Base"
|
27
|
+
# FIXME Needs to be cleaner
|
28
|
+
class_def = "# Author:: Luke Chadwick (mailto:luke.a.chadwick@gmail.com)\n"
|
29
|
+
class_def += "# Copyright:: Copyright (c) 2010 Luke Chadwick\n"
|
30
|
+
class_def += "# License:: Distributes under the same terms as Ruby\n"
|
31
|
+
class_def += "#\n"
|
32
|
+
class_def += "# This class is an auto generated documentum object type\n"
|
33
|
+
class_def += "class #{class_name} < #{parent_name}\n"
|
34
|
+
type[:properties].each do |property|
|
35
|
+
class_def += " # #{property[:name]} => #{property.inspect}\n"
|
36
|
+
end
|
37
|
+
class_def += "end"
|
38
|
+
FileUtils.mkdir_p(@base_dir)
|
39
|
+
File.open(file_name, 'w') {|file| file.puts class_def }
|
40
|
+
end
|
41
|
+
autoload class_name.intern, file_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def load
|
45
|
+
@@schema[:types].each do |name|
|
46
|
+
load_type(name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|