class Object
Public Instance Methods
Internal method to “convert” legacy load methods to Ruby Service API
# File services-legacy.rb, line 122 def __legacy_load_item primary_key, *cache_or_opts, &load_block named_arguments = {} # Deal with compatibility: 'cache_or_opts' could be a cache or load options or both case cache_or_opts.size when 1 cache_or_opts = cache_or_opts[0] # FIXME: For Ruby <= 2.5 we cannot simply "convert" a Hash to named arguments using "**", # so instead we ensure that only Symbol keys are used! if cache_or_opts.is_a?(Hash) and cache_or_opts.keys.all? { |k| k.is_a?(Symbol) } # Use complete first part as named argument named_arguments.merge!(cache_or_opts) elsif cache_or_opts.is_a?(PIM::LRUCache) # Set first part as item_cache, if it actually is one named_arguments[:item_cache] = cache_or_opts end when 2 # Set first part as item_cache named_arguments[:item_cache] = cache_or_opts[0] # Add second part as load options named_arguments.merge!(cache_or_opts[1]) end load_block.call(named_arguments) end
# File services-legacy.rb, line 602 def __service name return PIM::Services.__proxy_service(name) end
Deprecated! Please use ‘PIM::Services::TaskService’!
# File services-legacy.rb, line 376 def add_comment_to_task(task_id, comment) PIM::Services::TaskService.add_comment_to_task(task_id, comment) end
Deprecated! Please use PIM::Services::AccountService.get_user!
# File services-legacy.rb, line 29 def broadcast_message(message, severity = :success, opts = {}) PIM::Services::AccountService.broadcast_message(message, severity, opts) end
# File services-legacy.rb, line 37 def complete_order(order_reference) __service(:shoppingCartService).completeCurrentOrder(order_reference) end
Deprecated! Please use PIM::Services::InvitationService.invite_organization!
# File services-legacy.rb, line 506 def create_email_invitation(email_address, invitation_type, language = nil, custom_values = {}) PIM::Services::InvitationService.invite_organization(email_address, invitation_type, language: language, custom_values: custom_values) end
# File services-legacy.rb, line 582 def create_selection query_string selection = com.lansa.lax.pim.model::Selection.new item_query = com.lansa.lax.pim::ItemQuery.new item_query.keyword = query_string selection.items_query = item_query return __service(:selectionService).createSelection(selection) end
Deprecated! Please use ‘PIM::Services::TaskService’!
# File services-legacy.rb, line 361 def create_task(task_hash) PIM::Services::TaskService.create_task(task_hash) end
Deprecated! Please use ‘create_task’
# File services-legacy.rb, line 366 def create_todo(task_hash) create_task(task_hash) end
# File services-legacy.rb, line 559 def delete_item primary_key __service(:itemService).deleteItem(primary_key) end
# File services-legacy.rb, line 563 def delete_items primary_keys __service(:itemService).deleteItems(primary_keys) end
# File services-legacy.rb, line 567 def delete_items_by_selection selection_id __service(:itemService).deleteItemsBySelection(selection_id) end
# File services-legacy.rb, line 438 def depublish_items(item_ids, destination_type, destination_id, destination_sub_id = nil, publication_values = {}) queue_publication(item_ids, "DELETE", destination_type, destination_id, destination_sub_id, publication_values) end
# File services-legacy.rb, line 236 def fill_store_options_from_options(store_options, options) # Set default values set_store_option(store_options, :setBroadcastUpdateEvent, true) # Set values from ruby options return nil if not options.respond_to?(:has_key?) set_store_option(store_options, :setAllowAudit, options[:allowAudit]) set_store_option(store_options, :setBroadcastUpdateEvent, options[:broadcastUpdateEvent]) set_store_option(store_options, :setCallAfterStore, options[:callAfterStore]) set_store_option(store_options, :setCallBeforeStore, options[:callBeforeStore]) set_store_option(store_options, :setDirty, options[:dirty]) set_store_option(store_options, :setMerge, options[:merge]) set_store_option(store_options, :setRecalculateStatistics, options[:recalculateStatistics]) set_store_option(store_options, :setUnique, options[:unique]) set_store_option(store_options, :setValidate, options[:validate]) end
Deprecated! Please use ‘PIM::Services::CommunicationChannelService’!
# File services-legacy.rb, line 336 def get_active_communication_channels type = nil PIM::Services::CommunicationChannelService.get_active_communication_channels type end
Deprecated! Please use PIM::Services::OrganizationService.get_base_url!
# File services-legacy.rb, line 14 def get_base_url PIM::Services::OrganizationService.get_base_url end
Deprecated! Please use ‘PIM::Services::CommunicationChannelService’!
# File services-legacy.rb, line 331 def get_communication_channel *args PIM::Services::CommunicationChannelService.get_communication_channel *args end
Deprecated! Please use ‘PIM::Services::CommunicationChannelService’!
# File services-legacy.rb, line 341 def get_communication_channel_template name PIM::Services::CommunicationChannelService.get_communication_channel_template name end
Deprecated! Please use PIM::Services::ContactService.get_contact!
# File services-legacy.rb, line 481 def get_contact(organization_id) PIM::Services::ContactService.get_contact(organization_id) end
Deprecated! Please use PIM::Services::ContactService.get_contact_by_id!
# File services-legacy.rb, line 486 def get_contact_by_id(contact_id) PIM::Services::ContactService.get_contact_by_id(contact_id) end
Deprecated! Please use PIM::Services::ContactService.get_contact_by_organization_id!
# File services-legacy.rb, line 491 def get_contact_by_organization_id(organization_id) PIM::Services::ContactService.get_contact_by_organization_id(organization_id) end
Deprecated! Please use ‘PIM::Services::ReviewService’!
# File services-legacy.rb, line 346 def get_item_review_as_reviewer(primary_key) PIM::Services::ReviewService.get_item_review_as_reviewer(primary_key) end
Deprecated! Please use ‘PIM::Services::ReviewService’!
# File services-legacy.rb, line 351 def get_item_review_as_supplier(primary_key, reviewer) PIM::Services::ReviewService.get_item_review_as_supplier(primary_key, reviewer) end
Get items for exportTaskId
export_task_id:
-
a string id, e.g. taken from a custom export like ‘context’
# File services-legacy.rb, line 550 def get_items_by_export_task_id export_task_id return [] if export_task_id.nil? __service(:exportService).getExportedItems(export_task_id) end
Get items for selectionId
selection_id:
-
a string id, e.g. taken from a custom export like ‘context’
# File services-legacy.rb, line 577 def get_items_by_selection_id selection_id return [] if selection_id.nil? __service(:selectionService).getItems(selection_id) end
Find items with tag.
tag:
-
a string tag, e.g. upload:123
# File services-legacy.rb, line 540 def get_items_by_tag tag __service(:itemService).findByTag(tag) end
Deprecated! Please directly use the same method from PIM::Services::MessagingService!
# File services-legacy.rb, line 405 def get_messaging_asset_content messaging_asset_id return PIM::Services::MessagingService.get_messaging_asset_content(messaging_asset_id) end
Deprecated! Please directly use the same method from PIM::Services::MessagingService!
# File services-legacy.rb, line 415 def get_messaging_asset_content_stream messaging_asset_id return PIM::Services::MessagingService.get_messaging_asset_content_stream(messaging_asset_id) end
Deprecated! Please use ‘PIM::Services::TaskService’!
# File services-legacy.rb, line 381 def get_open_tasks_for_item(item_primary_key, tag) PIM::Services::TaskService.get_open_tasks_for_item(item_primary_key, tag) end
Deprecated! Please use PIM::Services::OrganizationService.get_organization!
# File services-legacy.rb, line 9 def get_organization PIM::Services::OrganizationService.get_organization end
# File services-legacy.rb, line 530 def get_publication_tasks publication_group_id __service(:publicationService).getPublicationTasks(publication_group_id) end
Deprecated! Please use PIM::Services::AccountService.get_roles_for_user!
# File services-legacy.rb, line 24 def get_roles_for_user(user_id_or_email = nil) PIM::Services::AccountService.get_roles_for_user(user_id_or_email) end
# File services-legacy.rb, line 33 def get_shopping_card __service(:shoppingCartService).getCurrentShoppingCart end
Deprecated! Please use ‘PIM::Services::TranslationService’!
# File services-legacy.rb, line 386 def get_translations(locale) PIM::Services::TranslationService.get_translations(locale) end
Deprecated! Please use PIM::Services::AccountService.get_user!
# File services-legacy.rb, line 19 def get_user(user_id_or_email = nil) PIM::Services::AccountService.get_user(user_id_or_email) end
Deprecated! Please directly use the same method from PIM::Services::ProcessTaskService!
# File services-legacy.rb, line 521 def handle_task_retry_exception exception, &block PIM::Services::ProcessTaskService.handle_task_retry_exception(exception, &block) end
# File services-legacy.rb, line 598 def has_data_model_license? data_model return __service(:rubyUtilsService).hasDataModelLicense(data_model) end
Deprecated! Please directly use the same method from PIM::Services::InvitationService!
# File services-legacy.rb, line 511 def invite_colleague(email_address, opts = {}) PIM::Services::InvitationService.invite_colleague(email_address, opts) end
Deprecated! Please directly use the same method from PIM::Services::ProcessTaskService!
# File services-legacy.rb, line 516 def is_task_retry_exception exception PIM::Services::ProcessTaskService.is_task_retry_exception(exception) end
Deprecated! Please use PIM::Services::ItemService.convert_item_to_json!
# File services-legacy.rb, line 162 def item_as_json(item) PIM::Services::ItemService.convert_item_to_json(item) end
Deprecated! Please use ‘item_as_json’
# File services-legacy.rb, line 182 def item_as_map(item) item_as_json(item) end
Deprecated! Please use PIM::Services::ItemService.convert_item_to_xml!
# File services-legacy.rb, line 167 def item_as_xml(item) PIM::Services::ItemService.convert_item_to_xml(item) end
Deprecated! Please use PIM::Services::ItemService.convert_items_to_xml!
# File services-legacy.rb, line 172 def items_as_xml(items) PIM::Services::ItemService.convert_items_to_xml(items) end
# File services-legacy.rb, line 592 def license_require data_model, name path_prefix = __service(:rubyUtilsService).getLicensedDataModelPathPrefix() name = "#{path_prefix}#{data_model}/#{name}" require name end
# File services-legacy.rb, line 290 def load_file(path, gathering_key = nil) digital_asset = __service(:digitalAssetService).getContent(gathering_key, path) input_stream = digital_asset ? digital_asset.getContentStream() : nil input_stream ? input_stream.to_io : nil end
Legacy method to load an item by primary key. This will return the item in it’s “Java” form.
Deprecated! Please use PIM::Services::ItemService.get_item_as_java!
Parameters:
-
primary_key (
String
) : the primary key to load the item for. -
cache_or_opts (Array) : if size is 1:
either an "item cache" or a Hash containing options
if size is 2:
- first value is a "item cache" - second value is a Hash containing options
# File services-legacy.rb, line 55 def load_item primary_key, *cache_or_opts __legacy_load_item(primary_key, *cache_or_opts) do |named_arguments| PIM::Services::ItemService.get_item_as_java(primary_key, **named_arguments) end end
Legacy method to load an item by primary key. This will return the item in it’s “JSON” form.
Deprecated! Please use PIM::Services::ItemService.get_item_as_json!
Parameters:
-
primary_key (
String
) : the primary key to load the item for. -
cache_or_opts (Array) : if size is 1:
either an "item cache" or a Hash containing options
if size is 2:
- first value is a "item cache" - second value is a Hash containing options
# File services-legacy.rb, line 75 def load_item_as_json primary_key, *cache_or_opts __legacy_load_item(primary_key, *cache_or_opts) do |named_arguments| PIM::Services::ItemService.get_item_as_json(primary_key, **named_arguments) end end
Legacy method to load an item by primary key. This will return the item in it’s “Ruby” form.
Deprecated! Please use PIM::Services::ItemService.get_item_as_ruby!
Parameters:
-
primary_key (
String
) : the primary key to load the item for. -
cache_or_opts (Array) : if size is 1:
either an "item cache" or a Hash containing options
if size is 2:
- first value is a "item cache" - second value is a Hash containing options
# File services-legacy.rb, line 95 def load_item_as_ruby primary_key, *cache_or_opts __legacy_load_item(primary_key, *cache_or_opts) do |named_arguments| PIM::Services::ItemService.get_item_as_ruby(primary_key, **named_arguments) end end
Legacy method to load an item by primary key. This will return the item in it’s “XML” form.
Deprecated! Please use PIM::Services::ItemService.get_item_as_xml!
Parameters:
-
primary_key (
String
) : the primary key to load the item for. -
cache_or_opts (Array) : if size is 1:
either an "item cache" or a Hash containing options
if size is 2:
- first value is a "item cache" - second value is a Hash containing options
# File services-legacy.rb, line 115 def load_item_as_xml primary_key, *cache_or_opts __legacy_load_item(primary_key, *cache_or_opts) do |named_arguments| PIM::Services::ItemService.get_item_as_xml(primary_key, **named_arguments) end end
Load the item event history for the specified primary key.
By default, the list of events is sorted from oldest to newest. To change, set the option ‘newest_first: true’. Also, to limit to specific event types, set the option ‘event_type: <EVENT_TYPE>’
# File services-legacy.rb, line 269 def load_item_event_history(primary_key, opts = {}) newest_first = PIM.get_value(opts, 'newest_first') || false event_type = PIM.get_value(opts, 'event_type') || PIM.get_value(opts, 'event') PIM::Services::ItemService.get_item_event_history(primary_key, newest_first:newest_first, event_type: event_type) end
Deprecated! Please use ‘load_item’ with appropriate options!
# File services-legacy.rb, line 177 def load_item_with_publication primary_key, destination_id, sub_destination, item_cache = nil load_item(primary_key, item_cache, :destinationId => destination_id, :subDestination => sub_destination) end
# File services-legacy.rb, line 434 def publish_items(item_ids, destination_type, destination_id, destination_sub_id = nil, publication_values = {}) queue_publication(item_ids, "ADD", destination_type, destination_id, destination_sub_id, publication_values) end
# File services-legacy.rb, line 442 def queue_publication(item_ids, publication_type, destination_type, destination_id, destination_sub_id = nil, publication_values = {}) publication_destination = com.lansa.lax.pim.PublicationDestination.new if destination_type == 'CHANNEL' publication_destination.destination_type = com.lansa.lax.pim.DestinationType::COMMUNICATION_CHANNEL elsif destination_type == 'PLATFORM' publication_destination.destination_type = com.lansa.lax.pim.DestinationType::IN_PLATFORM else raise "'#{destination_type}' is not a valid destination type." end publication_destination.destination_id = destination_id publication_destination.sub_destination = destination_sub_id transition_hash = {} if publication_values publication_values.each do |key, value| transition_hash[key.to_s] = value end end if publication_type == 'ADD' __service(:publicationService).queuePublications( java.util.ArrayList.new(item_ids), publication_destination, java.util.LinkedHashMap.new(transition_hash) ) elsif publication_type == 'DELETE' __service(:publicationService).queueDePublications( java.util.ArrayList.new(item_ids), publication_destination, java.util.LinkedHashMap.new(transition_hash) ) else raise "'#{publication_type}' is not a valid publication type." end end
Deprecated! Please directly use the same method from PIM::Services::WorkflowService!
# File services-legacy.rb, line 526 def queue_workflow_task event_name, parameters = {} PIM::Services::WorkflowService.queue_workflow_task(event_name, parameters) end
# File services-legacy.rb, line 322 def recalculate_statistics(primaryKeys = nil) if primaryKeys __service(:statisticsService).queueStatisticCalculation(primaryKeys) else __service(:statisticsService).queueRecalculation() end end
# File services-legacy.rb, line 314 def revalidate_items(primaryKeys = nil) if primaryKeys __service(:itemService).queueRevalidateItems(primaryKeys) else __service(:itemService).queueRevalidateAllItems() end end
Deprecated! Please use PIM::Services::ContactService.search_contacts_by_custom_value!
# File services-legacy.rb, line 496 def search_contacts_by_custom_value(key, value) PIM::Services::ContactService.search_contacts_by_custom_value(key, value) end
Deprecated! Please use ‘search_items_by_keyword’
# File services-legacy.rb, line 420 def search_item keyword search_items_by_keyword keyword end
Deprecated! Please use PIM::Services::ItemService.search_items!
# File services-legacy.rb, line 425 def search_items_by_keyword keyword, opts = {} PIM::Services::ItemService.search_items(keyword: keyword, **opts) end
Deprecated! Please use PIM::Services::ItemService.search_items!
# File services-legacy.rb, line 430 def search_items_by_tag tag, opts = {} PIM::Services::ItemService.search_items(tag: tag, **opts) end
# File services-legacy.rb, line 395 def send_email(email, locale = nil) __service(:emailService).send_mail(email[:subject], email[:message], email[:from], email[:to], locale) end
Deprecated! Please use ‘PIM::Services::ReviewService’!
# File services-legacy.rb, line 356 def send_review(review_hash) PIM::Services::ReviewService.send_review(review_hash) end
# File services-legacy.rb, line 296 def send_webservice_request(webservice_name, req) __service(:webserviceCommunicationService).request(webservice_name, req) end
# File services-legacy.rb, line 256 def set_store_option store_options, store_method, value if not value.nil? store_options.send(store_method, value) end end
# File services-legacy.rb, line 275 def store_file(path, content) content = case when content.is_a?(String) java.io.ByteArrayInputStream.new(content.to_java.get_bytes("UTF-8")) when content.is_a?(IO) content.to_inputstream else java.io.ByteArrayInputStream.new(content.to_s.to_java_bytes) end __service(:digitalAssetService).createDigitalAsset(content, path, "ruby") end
Stores an item.
item:
-
the item to store
tags: (default empty Array): add tag for the item
-
:upload : a string tag, e.g. upload:123
-
:dataModel : a string tag, e.g. dataModel:123
options:
-
allowAudit : (default false) : Allows to modify the audited state of the item
-
broadcastUpdateEvent : (default true) : broadcasting update events
-
callBeforeStore : (default true) : calls the before store method of the datamodel if true
-
dirty : (default false) : indicates if the item is validated or not
-
merge : (default true) : merges the item into the stored item including the tags
-
unique : (default false) : checks the primary key uniqueness of the item
-
validate : (default true) : validates the item and stores the statistics if true
-
disableValidation : (default false) : indicates validation disable or not
# File services-legacy.rb, line 204 def store_item(item, tags = nil, options = nil) return nil if item.nil? # Convert Ruby item and Hash item to JSON string to prevent problems with Ruby objects being used in different runtimes if !item.is_a?(com.lansa.lax.pim::Item) if item.is_a?(PIM::Item) item = PIM.return_json(item.as_json) elsif PIM.is_hash?(item) item = PIM.return_json(item) end return nil if PIM.is_empty?(item) if !PIM.is_string?(item) raise "Cannot store item of class #{item.class}" end end store_options = com.lansa.lax.pim::ItemStoreOptions.getDefaultOptions fill_store_options_from_options(store_options, options) # Ensure, tags is a collection tags = Array(tags) unless tags.nil? or PIM.is_collection?(tags) # 'item' can only be a Java Item or a JSON String (see above!) __service(:itemService).storeFromRuby(item, tags, store_options) end
Deprecated! Please use ‘PIM::Services::TranslationService’!
# File services-legacy.rb, line 391 def translate(locale, key, params = {}) PIM::Services::TranslationService.translate(locale, key, params) end
Deprecated! Please use PIM::Services::OrganizationService.update_managed_organization!
# File services-legacy.rb, line 501 def update_managed_organization managed_organization_id, params = {} PIM::Services::OrganizationService.update_managed_organization(managed_organization_id, params) end
Deprecated! Please directly use the same method from PIM::Services::MessagingService!
# File services-legacy.rb, line 400 def update_message reference_message_id, new_status, status_message, response_id PIM::Services::MessagingService.update_message(reference_message_id, new_status, status_message, response_id) end
Deprecated! Please use ‘PIM::Services::TaskService’!
# File services-legacy.rb, line 371 def update_task(task) PIM::Services::TaskService.update_task(task) end
Deprecated! Please directly use the same method from PIM::Services::MessagingService!
# File services-legacy.rb, line 410 def upload_inbound_message_from_stream stream, filename, content_type, channel_id PIM::Services::MessagingService.upload_inbound_message_from_stream(stream, filename, content_type, channel_id) end
# File services-legacy.rb, line 310 def write_activity(message) __service(:monitoringService).write("ACTIVITY", message) end
# File services-legacy.rb, line 300 def write_log(message, log_level = nil, exception = nil) monitoring_module = log_level ? "RUBY_#{log_level.to_s.upcase}" : "RUBY" exception = PIM.to_java_exception(exception) if __service(:monitoringService) __service(:monitoringService).write(monitoring_module, message, nil, exception) else $stderr.puts "#{monitoring_module}: #{message}" end end