Module: ArchestryLookup::Objects

Defined in:
lib/objects/_old.rb,
lib/objects/lookup.rb,
lib/context/archestry/prepost.rb

Class Method Summary collapse

Class Method Details

.archestryLookupView(args, lookupType, lookup, state, modelType, viewId) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# 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) ⇒ Object



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
# 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) ⇒ Object



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
# 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) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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

.lookup_post(args, state) ⇒ Object



20
21
22
# File 'lib/context/archestry/prepost.rb', line 20

def lookup_post(args, state)
  true
end

.lookup_post2(args, state) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# 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) ⇒ Object



16
17
18
# File 'lib/context/archestry/prepost.rb', line 16

def lookup_pre(args, state)
  true
end

.lookup_run(args, lookupStruct, state, modelType, viewId) ⇒ Object



141
142
143
144
145
146
147
# 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

.lookupDebug(name, prop) ⇒ Object



136
137
138
# 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

.makeStageView(args, state, conProp, modelType, viewId, queryName, lookup, cClass) ⇒ Object



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
# 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