######## ####### ######## ####### ######## ######## ## / / / / License \ \ \ \ ## Copyleft culture, Copyright (C) is prohibited here ## This work is licensed under a CC BY-SA 4.0 ## Creative Commons Attribution-ShareAlike 4.0 License ## Refer to the http://creativecommons.org/licenses/by-sa/4.0/ ######## ####### ######## ####### ######## ######## ## / / / / Code Climate \ \ \ \ ## Language = ruby ## Indent = space; 4 chars; ######## ####### ######## ####### ######## ######## module ArchestryLookup module Objects class << self 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 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 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 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 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 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 end end end