module OEHClient::Meta::Entity

Constants

ONE_PARAM_CREATED_BY
ONE_PARAM_CREATED_ON
ONE_PARAM_DATA

————- Constants

ONE_PARAM_ID
ONE_PARAM_ITEMS
ONE_PARAM_NAME
ONE_PARAM_SUCCESS

Public Instance Methods

create() click to toggle source

————- Helper Class Methods

# File lib/oehclient/meta/entity.rb, line 40
def create()
end
entity_uri_stem() click to toggle source
# File lib/oehclient/meta/entity.rb, line 24
def entity_uri_stem
        @entity_stem
end
entity_uri_stem=(uri_stem) click to toggle source

————- Class Attributes

# File lib/oehclient/meta/entity.rb, line 20
def entity_uri_stem=(uri_stem)
        @entity_stem = uri_stem
end
find_by_name(active_session, name, **args) click to toggle source
# File lib/oehclient/meta/entity.rb, line 43
def find_by_name(active_session, name,  **args)
        get(active_session, {:name => ONE_PARAM_NAME, :value => name}, args)
end
get(active_session, attribute_nvp, **args) click to toggle source
# File lib/oehclient/meta/entity.rb, line 69
def get(active_session, attribute_nvp, **args)
        # store the active session object for future use
        session = active_session      if (session.nil?)
        # initialize the entity instance as a blank hash
        entity_instance = Hash.new
        # Get the collection of objects requested
        get_collection(session, **args).each do | collection_instance |
                puts "-----] Collection Instance: #{collection_instance}"
                # find the matching entry and assign the entity instance
                entity_instance = collection_instance if (collection_instance[attribute_nvp[:name]].casecmp(attribute_nvp[:value]) == 0)
        end # Each OEHClient::Meta::Entity.get_collection
        # return the copy of the entity instance data
        entity_instance
end
get_collection(active_session, **args) click to toggle source

————- Core Class Methods

# File lib/oehclient/meta/entity.rb, line 51
def get_collection(active_session, **args)
        # store the active session object for future use
        self.session = active_session         if (session.nil?)
        # get the list of args
        entity_uri = (args.has_key?(:space)) ? "workspaces/#{args[:space]}/#{entity_uri_stem}" : "#{entity_uri_stem}" 
        # construct the URL for retrieving the entity
        url = "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{self.session.space.host}/one/services/api/#{entity_uri}"
        # set the header information
        header = (!self.session.cookies.nil? ? {:cookies => self.session.cookies}.merge!(OEHClient::Helper::Request.default_JSON_header()) : OEHClient::Helper::Request.default_JSON_header())
        # construct the request params using the header and params (if passed)
        request_params = {:header => header}
        request_params.merge!({:params => args[:params]})             if (args.has_key?(:params))
        # GET the data
        collection_response = OEHClient.get(url, nil, request_params)
        # return the data object for valid requests or a blank array otherwise
        ((collection_response.has_key?(:body) && collection_response[:body][ONE_PARAM_SUCCESS]) ? (collection_response[:body][ONE_PARAM_DATA].is_a?(Hash) ? collection_response[:body][ONE_PARAM_DATA][ONE_PARAM_ITEMS] : collection_response[:body][ONE_PARAM_DATA]) : [] )
end
session() click to toggle source
# File lib/oehclient/meta/entity.rb, line 32
def session
        @session
end
session=(session_instance) click to toggle source
# File lib/oehclient/meta/entity.rb, line 28
def session=(session_instance)
        @session = session_instance
end