module ArchestryLookup::Objects

Public Class Methods

archestryLookupView(args, lookupType, lookup, state, modelType, viewId) click to toggle source
# File lib/objects/lookup.rb, line 17
def archestryLookupView(args, lookupType, lookup, state, modelType, viewId)
  if args[:objects][:view][modelType][viewId]
    if lookup[:cClass] == '*'
      args[:objects][:view][modelType][viewId][:links].each do |cClass, cProp|
        archestryLookupViewRun(args, state, lookupType, lookup, modelType, viewId, cClass)
      end
    else
      archestryLookupViewRun(args, state, lookupType, lookup, modelType, viewId, lookup[:cClass])
    end
  end
end
archestryLookupViewRun(args, state, lookupType, lookup, modelType, viewId, cClass) click to toggle source
# File lib/objects/lookup.rb, line 30
      def archestryLookupViewRun(args, state, lookupType, lookup, modelType, viewId, cClass)
        queryName = lookupType
        if args[:objects][:view][modelType][viewId][:links][cClass].is_a?(Hash)
          args[:objects][:view][modelType][viewId][:links][cClass].each do |_conPairId, conProp|
          
            lookup[:fClass] == '*' ? fClass = /^*/ : fClass = /^#{lookup[:fClass]}/
            lookup[:tClass] == '*' ? tClass = /^*/ : tClass = /^#{lookup[:tClass]}/
            
            fPropMod = []
            fPropMod << :fPropsKAll if lookup[:fPropsK] == '*'
            fPropMod << :fPropsVAll if lookup[:fPropsV] == '*'
            fPropMod << :fPropsAll if fPropMod.include?(:fPropsKAll) and fPropMod.include?(:fPropsVAll)
            
            tPropMod = []
            tPropMod << :tPropsKAll if lookup[:tPropsK] == '*'
            tPropMod << :tPropsVAll if lookup[:tPropsV] == '*'
            tPropMod << :tPropsAll if tPropMod.include?(:tPropsKAll) and tPropMod.include?(:tPropsVAll)
            
            if fPropMod.include?(:fPropsKAll)
              fPropsFiltered = true
            elsif fPropMod.include?(:fPropsVAll)
              fPropsFiltered = true if conProp[:fProps].has_key?(lookup[:fPropsK])
            else
              fPropsFiltered = true if conProp[:fProps][lookup[:fPropsK]] =~ /^#{lookup[:fPropsV]}/
            end
            
            if tPropMod.include?(:tPropsKAll)
              tPropsFiltered = true
            elsif tPropMod.include?(:tPropsVAll)
              tPropsFiltered = true if conProp[:tProps].has_key?(lookup[:tPropsK])
            else
#               tPropsFiltered = true if conProp[:tProps][lookup[:tPropsK]] =~ /^#{lookup[:tPropsV]}/
            end
          
            
          if  conProp[:viewID] == viewId and
              conProp[:fClass] =~ fClass and 
              conProp[:tClass] =~ tClass and
              fPropsFiltered == true and 
              tPropsFiltered == true 
                makeStageView(args, state, conProp, modelType, viewId, queryName, lookup, cClass)
            end
          end
        end
      end
archestryRepack(args, lookup, state, modelType, viewId, viewType) click to toggle source
# File lib/objects/lookup.rb, line 107
def archestryRepack(args, lookup, state, modelType, viewId, viewType) 
  args[:stages].each do |k, v|
    a = args[:stages][k]
    pp viewType
    unless a.has_key?(viewType) and a.has_key?(viewType) and not a[viewId].nil?
      base = false
    else
      base = a[viewId][queryName]          
    end
  end

  if base.is_a?(Hash)
    repackNames = [:fProps, :tProps, :fOID, :tOID, :fEID, :tEID]              
    base[:repack] = {}      
    repackNames.each do |repackName|
      res = {}                     
      base[:repack][repackName] ||= {}      
      base[:lookup].each do |_tName, hash_tNameProp|
        hash_tNameProp.each do |_fName, hash_fNameProp|
          res[hash_fNameProp[repackName]] = hash_fNameProp
        end 
      end  

      a[viewId][queryName][:repack][repackName] = res               
    end      
  end
end
getProp(_args,state,conProp,direction) click to toggle source
# File lib/objects/_old.rb, line 16
    def getProp(_args,state,conProp,direction)
      rows = {}
      case direction
      when 'from'
        eID  = conProp[:fEID]
        eVer = conProp[:fEVer]        
      when 'to'
        eID  = conProp[:tEID]
        eVer = conProp[:tEVer]        
      end
      
      ArchestryLookup::Sql.sqlQuery(state,  "
        select name, value                  
        from properties 
        where parent_id like '#{eID}' AND
        parent_version = '#{eVer}' AND
        name NOT LIKE 'fqn'
      ")  do |row|
#             ArchestryLookup.logger.debug "### ROW #{eID} #: #{row}"
            rows[row[0].to_sym] = row[1]             
      end  
      return rows if not rows.empty?
    end
lookupDebug(name, prop) click to toggle source
# File lib/objects/lookup.rb, line 136
def lookupDebug(name, prop)
  ArchestryLookup.logger.debug "### #{name} :: F:: '#{prop[:fName]}' fqn:#{prop[:fProps]} o:#{prop[:fOID]} e:#{prop[:fEID]} p '#{prop[:fProp]}' :: T :: '#{prop[:tName]}' fqn:#{prop[:tProps]} o:#{prop[:tOID]} e:#{prop[:tEID]} p '#{prop[:tProp]}'"
end
lookup_post(args, state) click to toggle source
# File lib/context/archestry/prepost.rb, line 20
def lookup_post(args, state)
  true
end
lookup_post2(args, state) click to toggle source
# File lib/context/archestry/prepost.rb, line 25
      def lookup_post2(args, state)
#         pp args[:folders]
        args[:views][:mtype].each do |modelType, ids| 
          ids.each do |id|
            args[:views][:id][id].each do |viewId, viewProps|
              ArchestryLookup.logger.debug "ArchestryLookup_lookup RUN instance '' view '#{viewProps}' ver."
              lookup_run(args, ArchestryLookup::Schema.getObjLookupSchema, state, modelType, id)
            end
          end
        end
      end
lookup_pre(args, state) click to toggle source
# File lib/context/archestry/prepost.rb, line 16
def lookup_pre(args, state)
  true
end
lookup_run(args, lookupStruct, state, modelType, viewId) click to toggle source
# File lib/objects/lookup.rb, line 141
      def lookup_run(args, lookupStruct, state, modelType, viewId)
        lookupStruct.each do |lookupType, lookup|
          ArchestryLookup.logger.debug "### ArchestryLookup_lookup call - type::#{lookupType}, lookupStruct::#{lookupStruct}"        
          archestryLookupView(args, lookupType, lookup, state, modelType, viewId)
#           archestryRepack(args, lookupType, lookup, state, modelType, viewId)
        end
      end
makeStageView(args, state, conProp, modelType, viewId, queryName, lookup, cClass) click to toggle source
# File lib/objects/lookup.rb, line 77
      def makeStageView(args, state, conProp, modelType, viewId, queryName, lookup, cClass)
        conProp[:cClass] = cClass

        if lookup.has_key?(:fPropKey)
          conProp[:fProp][lookup[:fPropKey]] == lookup[:fPropValue] ? store = true : store = false
        else
          store = true
        end
        
        if store == true    
#                 hash_fName = Digest::SHA256.hexdigest("#{conProp[:fName]}")[0..20]
          hash_tName = Digest::SHA256.hexdigest("#{conProp[:tName]}")[0..20]
          hash_fName_fId_tId = Digest::SHA256.hexdigest("#{conProp[:fName]}#{conProp[:fOID]}#{conProp[:tOID]}")[0..20]              
#
#           if conProp[:fProps].is_a?(Hash) and conProp[:fProps].has_key?('listenIP') and conProp[:fProps]['listenIP'] == '1.1.1.1'
#             pp "fProps:: conProp:#{conProp}"
#           elsif conProp[:tProps].is_a?(Hash) and conProp[:tProps].has_key?('listenIP')
#             pp "tProps:: conProp:#{conProp}"
#           end
          
          args[:stages][:view][modelType] ||= {}
          args[:stages][:view][modelType][viewId] ||= {}
          args[:stages][:view][modelType][viewId][queryName] ||= {}              
          args[:stages][:view][modelType][viewId][queryName][:lookup] ||= {}
          args[:stages][:view][modelType][viewId][queryName][:lookup][hash_tName] ||= {}
          args[:stages][:view][modelType][viewId][queryName][:lookup][hash_tName][hash_fName_fId_tId] = conProp                   
        end
      end