class AssignmentsImpl(Assignments): """ generated source for class AssignmentsImpl """ empty = bool() allDone = False # Contains all the assignments of variables we could make headAssignment = Map() varsToAssign = List() valuesToIterate = List() valuesToCompute = List() indicesToChangeWhenNull = List() # See note below distincts = List() varsToChangePerDistinct = List() # indexing same as distincts # # * What does indicesToChangeWhenNull do? Well, sometimes after incrementing # * part of the iterator, we find that a function being used to define a slot # * in the tuple has no value corresponding to its inputs (the inputs are # * outside the function's domain). In that case, we set the value to null, # * then leave it to the makeNextAssignmentValid() method to deal with it. # * We want to increment something in the input, but we need to know what # * in the input we should increment (i.e. which is the rightmost slot in # * the function's input). This is recorded in indicesToChangeWhenNull. If # * a slot is not defined by a function, then presumably it will not be null, # * so its value here is unimportant. Setting its value to -1 would help # * catch errors. # tuplesBySource = List() # indexed by conjunct sourceDefiningSlot = List() # indexed by var slot varsChosenBySource = List() # indexed by conjunct, then slot putDontCheckBySource = List() # indexed by conjunct, then slot # # * Creates an Assignments object that generates AssignmentIterators. # * These can be used to efficiently iterate over all possible assignments # * for variables in a given rule. # * # * @param headAssignment An assignment of variables whose values should be # * fixed. May be empty. # * @param rule The rule whose assignments we want to iterate over. # * @param varDomains A map containing the possible values for each variable # * in the rule. (All such values are GdlConstants.) # * @param functionInfoMap # * @param completedSentenceFormValues # @overloaded def __init__(self, headAssignment, rule, varDomains, functionInfoMap, completedSentenceFormValues): """ generated source for method __init__ """ super(AssignmentsImpl, self).__init__() self.empty = False self.headAssignment = headAssignment # We first have to find the remaining variables in the body self.varsToAssign = GdlUtils.getVariables(rule) # Remove all the duplicates; we do, however, want to keep the ordering newVarsToAssign = ArrayList() for v in varsToAssign: if not newVarsToAssign.contains(v): newVarsToAssign.add(v) self.varsToAssign = newVarsToAssign self.varsToAssign.removeAll(headAssignment.keySet()) # varsToAssign is set at this point # We see if iterating over entire tuples will give us a # better result, and we look for the best way of doing that. # Let's get the domains of the variables # Map<GdlVariable, Set<GdlConstant>> varDomains = model.getVarDomains(rule); # Since we're looking at a particular rule, we can do this one step better # by looking at the domain of the head, which may be more restrictive # and taking the intersections of the two domains where applicable # Map<GdlVariable, Set<GdlConstant>> headVarDomains = model.getVarDomainsInSentence(rule.getHead()); # We can run the A* search for a good set of source conjuncts # at this point, then use the result to build the rest. completedSentenceFormSizes = HashMap() if completedSentenceFormValues != None: for form in completedSentenceFormValues.keySet(): completedSentenceFormSizes.put(form, completedSentenceFormValues.get(form).size()) varDomainSizes = HashMap() for var in varDomains.keySet(): varDomainSizes.put(var, varDomains.get(var).size()) bestOrdering = IterationOrderCandidate() bestOrdering = getBestIterationOrderCandidate(rule, varDomains, functionInfoMap, completedSentenceFormSizes, headAssignment, False)# model, # TODO: True here? # Want to replace next few things with order # Need a few extra things to handle the use of iteration over existing tuples self.varsToAssign = bestOrdering.getVariableOrdering() # For each of these vars, we have to find one or the other. # Let's start by finding all the domains, a task already done. self.valuesToIterate = Lists.newArrayListWithCapacity(len(self.varsToAssign)) for var in varsToAssign: if varDomains.containsKey(var): if not varDomains.get(var).isEmpty(): self.valuesToIterate.add(ImmutableList.copyOf(varDomains.get(var))) else: self.valuesToIterate.add(ImmutableList.of(GdlPool.getConstant("0"))) else: self.valuesToIterate.add(ImmutableList.of(GdlPool.getConstant("0"))) # Okay, the iteration-over-domain is done. # Now let's look at sourced iteration. self.sourceDefiningSlot = ArrayList(len(self.varsToAssign)) i = 0 while i < len(self.varsToAssign): self.sourceDefiningSlot.add(-1) i += 1 # We also need to convert values into tuples # We should do so while constraining to any constants in the conjunct # Let's convert the conjuncts sourceConjuncts = bestOrdering.getSourceConjuncts() self.tuplesBySource = Lists.newArrayListWithCapacity(len(sourceConjuncts)) # new ArrayList<List<List<GdlConstant>>>(len(sourceConjuncts)); self.varsChosenBySource = Lists.newArrayListWithCapacity(len(sourceConjuncts)) # new ArrayList<List<Integer>>(len(sourceConjuncts)); self.putDontCheckBySource = Lists.newArrayListWithCapacity(len(sourceConjuncts)) # new ArrayList<List<Boolean>>(len(sourceConjuncts)); j = 0 while j < len(sourceConjuncts): # flatten into a tuple # Go through the vars/constants in the tuple while i < len(conjunctTuple): if isinstance(term, (GdlConstant, )): constraintSlots.add(i) constraintValues.add(term) # TODO: What if tuple size ends up being 0? # Need to keep that in mind elif isinstance(term, (GdlVariable, )): varsChosen.add(varIndex) if self.sourceDefiningSlot.get(varIndex) == -1: # We define it self.sourceDefiningSlot.set(varIndex, j) putDontCheck.add(True) else: # It's an overlap; we just check for consistency putDontCheck.add(False) else: raise RuntimeException("Function returned in tuple") i += 1 self.varsChosenBySource.add(ImmutableList.copyOf(varsChosen)) self.putDontCheckBySource.add(ImmutableList.copyOf(putDontCheck)) # Now we put the tuples together # We use constraintSlots and constraintValues to check that the # tuples have compatible values for sentence in sentences: # Check that it doesn't conflict with our headAssignment if not headAssignment.isEmpty(): for var in headAssignment.keySet(): if tupleAssignment.containsKey(var) and tupleAssignment.get(var) != headAssignment.get(var): continue while c < len(constraintSlots): if not longTuple.get(slot) == value: continue c += 1 while s < len(longTuple): # constraintSlots is sorted in ascending order if c < len(constraintSlots) and constraintSlots.get(c) == s: c += 1 else: shortTuple.add(longTuple.get(s)) s += 1 # The tuple fits the source conjunct tuples.add(ImmutableList.copyOf(shortTuple)) # sortTuples(tuples); //Needed? Useful? Not sure. Probably not? self.tuplesBySource.add(ImmutableList.copyOf(tuples)) j += 1 # We now want to see which we can give assignment functions to self.valuesToCompute = ArrayList(len(self.varsToAssign)) for var in varsToAssign: self.valuesToCompute.add(None) self.indicesToChangeWhenNull = ArrayList(len(self.varsToAssign)) i = 0 while i < len(self.varsToAssign): # Change itself, why not? # Actually, instead let's try -1, to catch bugs better self.indicesToChangeWhenNull.add(-1) i += 1 # Now we have our functions already selected by the ordering # bestOrdering.functionalConjunctIndices; # Make AssignmentFunctions out of the ordering functionalConjuncts = bestOrdering.getFunctionalConjuncts() # print "functionalConjuncts: " + functionalConjuncts; i = 0 while i < len(functionalConjuncts): if functionalConjunct != None: # These are the only ones that could be constant functions if functionInfoMap != None: functionInfo = functionInfoMap.get(conjForm) if functionInfo != None: # Now we need to figure out which variables are involved # and which are suitable as functional outputs. # 1) Which vars are in this conjunct? # 2) Of these vars, which is "rightmost"? # 3) Is it only used once in the relation? if Collections.frequency(varsInSentence, rightmostVar) != 1: continue # Can't use it # 4) Which slot is it used in in the relation? # 5) Build an AssignmentFunction if appropriate. # This should be able to translate from values of # the other variables to the value of the wanted # variable. # We don't guarantee that this works until we check if not function_.functional(): continue self.valuesToCompute.set(index, function_) remainingVarsInSentence.remove(rightmostVar) self.indicesToChangeWhenNull.set(index, self.varsToAssign.indexOf(nextRightmostVar)) i += 1 # We now have the remainingVars also assigned their domains # We also cover the distincts here # Assume these are just variables and constants self.distincts = ArrayList() for literal in rule.getBody(): if isinstance(literal, (GdlDistinct, )): self.distincts.add(literal) computeVarsToChangePerDistinct() # Need to add "distinct" restrictions to head assignment, too... checkDistinctsAgainstHead() # We are ready for iteration # print "headAssignment: " + headAssignment; # print "varsToAssign: " + varsToAssign; # print "valuesToCompute: " + valuesToCompute; # print "sourceDefiningSlot: " + sourceDefiningSlot; def getRightmostVar(self, vars): """ generated source for method getRightmostVar """ rightmostVar = None for var in varsToAssign: if vars.contains(var): rightmostVar = var return rightmostVar @__init__.register(object) def __init___0(self): """ generated source for method __init___0 """ super(AssignmentsImpl, self).__init__() # The assignment is impossible; return nothing self.empty = True @SuppressWarnings("unchecked") @__init__.register(object, GdlRule, Map, Map, Map) def __init___1(self, rule, varDomains, functionInfoMap, completedSentenceFormValues): """ generated source for method __init___1 """ super(AssignmentsImpl, self).__init__() # SentenceModel model, self.__init__(Collections.EMPTY_MAP, rule, varDomains, functionInfoMap, completedSentenceFormValues) def checkDistinctsAgainstHead(self): """ generated source for method checkDistinctsAgainstHead """ for distinct in distincts: if term1 == term2: # This fails self.empty = True self.allDone = True def iterator(self): """ generated source for method iterator """ return AssignmentIteratorImpl(getPlan()) def getIterator(self): """ generated source for method getIterator """ return AssignmentIteratorImpl(getPlan()) def getPlan(self): """ generated source for method getPlan """ return AssignmentIterationPlan.create(self.varsToAssign, self.tuplesBySource, self.headAssignment, self.indicesToChangeWhenNull, self.distincts, self.varsToChangePerDistinct, self.valuesToCompute, self.sourceDefiningSlot, self.valuesToIterate, self.varsChosenBySource, self.putDontCheckBySource, self.empty, self.allDone) def computeVarsToChangePerDistinct(self): """ generated source for method computeVarsToChangePerDistinct """ # remember that iterators must be set up first self.varsToChangePerDistinct = ArrayList(len(self.varsToAssign)) for distinct in distincts: # For two vars, we want to record the later of the two # For one var, we want to record the one # For no vars, we just put null if isinstance(, (GdlVariable, )): varsInDistinct.add(distinct.getArg1()) if isinstance(, (GdlVariable, )): varsInDistinct.add(distinct.getArg2()) if len(varsInDistinct) == 1: varToChange = varsInDistinct.get(0) elif len(varsInDistinct) == 2: varToChange = self.getRightmostVar(varsInDistinct) self.varsToChangePerDistinct.add(varToChange) @classmethod def getAssignmentsProducingSentence(cls, rule, sentence, varDomains, functionInfoMap, completedSentenceFormValues): """ generated source for method getAssignmentsProducingSentence """ # SentenceModel model, # First, we see which variables must be set according to the rule head # (and see if there's any contradiction) headAssignment = HashMap() if not setVariablesInHead(rule.getHead(), sentence, headAssignment): return AssignmentsImpl() # Collections.emptySet(); # Then we come up with all the assignments of the rest of the variables # We need to look for functions we can make use of return AssignmentsImpl(headAssignment, rule, varDomains, functionInfoMap, completedSentenceFormValues) # returns true if all variables were set successfully @classmethod @overloaded def setVariablesInHead(cls, head, sentence, assignment): """ generated source for method setVariablesInHead """ if isinstance(head, (GdlProposition, )): return True return cls.setVariablesInHead(head.getBody(), sentence.getBody(), assignment) @classmethod @setVariablesInHead.register(object, List, List, Map) def setVariablesInHead_0(cls, head, sentence, assignment): """ generated source for method setVariablesInHead_0 """ i = 0 while i < len(head): if isinstance(headTerm, (GdlConstant, )): if not refTerm == headTerm: # The rule can't produce this sentence return False elif isinstance(headTerm, (GdlVariable, )): if curValue != None and not curValue == refTerm: # inconsistent assignment (e.g. head is (rel ?x ?x), sentence is (rel 1 2)) return False assignment.put(var, refTerm) elif isinstance(headTerm, (GdlFunction, )): # Recurse on the body if not cls.setVariablesInHead(headFunction.getBody(), refFunction.getBody(), assignment): return False i += 1 return True # # * Finds the iteration order (including variables, functions, and # * source conjuncts) that is expected to result in the fastest iteration. # * # * The value that is compared for each ordering is the product of: # * - For each source conjunct, the number of tuples offered by the conjunct; # * - For each variable not defined by a function, the size of its domain. # * # * @param functionInfoMap # * @param completedSentenceFormSizes For each sentence form, this may optionally # * contain the number of possible sentences of this form. This is useful if the # * number of sentences is much lower than the product of its variables' domain # * sizes; however, if this contains sentence forms where the set of sentences # * is unknown, then it may return an ordering that is unusable. # @classmethod def getBestIterationOrderCandidate(cls, rule, varDomains, functionInfoMap, completedSentenceFormSizes, preassignment, analyticFunctionOrdering): """ generated source for method getBestIterationOrderCandidate """ # SentenceModel model, # Here are the things we need to pass into the first IOC constructor sourceConjunctCandidates = ArrayList() # What is a source conjunct candidate? # - It is a positive conjunct in the rule (i.e. a GdlSentence in the body). # - It has already been fully defined; i.e. it is not recursively defined in terms of the current form. # Furthermore, we know the number of potentially true tuples in it. varsToAssign = GdlUtils.getVariables(rule) newVarsToAssign = ArrayList() for var in varsToAssign: if not newVarsToAssign.contains(var): newVarsToAssign.add(var) varsToAssign = newVarsToAssign if preassignment != None: varsToAssign.removeAll(preassignment.keySet()) # Calculate var domain sizes varDomainSizes = getVarDomainSizes(varDomains)# rule, model sourceConjunctSizes = ArrayList() for conjunct in rule.getBody(): if isinstance(conjunct, (GdlRelation, )): if completedSentenceFormSizes != None and completedSentenceFormSizes.containsKey(form): # New: Don't add if it will be useless as a source # For now, we take a strict definition of that # Compare its size with the product of the domains # of the variables it defines # In the future, we could require a certain ratio # to decide that this is worthwhile for var in vars: maxSize *= domainSize if size >= maxSize: continue sourceConjunctCandidates.add(relation) sourceConjunctSizes.add(size) functionalSentences = ArrayList() functionalSentencesInfo = ArrayList() for conjunct in rule.getBody(): if isinstance(conjunct, (GdlSentence, )): if functionInfoMap != None and functionInfoMap.containsKey(form): functionalSentences.add(conjunct) functionalSentencesInfo.add(functionInfoMap.get(form)) # TODO: If we have a head assignment, treat everything as already replaced # Maybe just translate the rule? Or should we keep the pool clean? emptyCandidate = IterationOrderCandidate(varsToAssign, sourceConjunctCandidates, sourceConjunctSizes, functionalSentences, functionalSentencesInfo, varDomainSizes) searchQueue = PriorityQueue() searchQueue.add(emptyCandidate) while not searchQueue.isEmpty(): # print "Node being checked out: " + curNode; if curNode.isComplete(): # This is the complete ordering with the lowest heuristic value return curNode searchQueue.addAll(curNode.getChildren(analyticFunctionOrdering)) raise RuntimeException("Found no complete iteration orderings") @classmethod def getVarDomainSizes(cls, varDomains): """ generated source for method getVarDomainSizes """ # GdlRule rule, # SentenceModel model varDomainSizes = HashMap() # Map<GdlVariable, Set<GdlConstant>> varDomains = model.getVarDomains(rule); for var in varDomains.keySet(): varDomainSizes.put(var, varDomains.get(var).size()) return varDomainSizes @classmethod def getNumAssignmentsEstimate(cls, rule, varDomains, checker): """ generated source for method getNumAssignmentsEstimate """ # First we need the best iteration order # Arguments we'll need to pass in: # - A SentenceModel # - constant forms # - completed sentence form sizes # - Variable domain sizes? functionInfoMap = HashMap() for form in checker.getConstantSentenceForms(): functionInfoMap.put(form, FunctionInfoImpl.create(form, checker)) # Populate variable domain sizes using the constant checker domainSizes = HashMap() for form in checker.getConstantSentenceForms(): domainSizes.put(form, checker.getTrueSentences(form).size()) # TODO: Propagate these domain sizes as estimates for other rules? # Look for literals in the body of the rule and their ancestors? # Could we possibly do this elsewhere? ordering = cls.getBestIterationOrderCandidate(rule, varDomains, functionInfoMap, None, None, True)# model, return ordering.getHeuristicValue()
def infrastructure(client, OSHVResult, Framework, schemaName=None, viewSchemaName=None): retOSHs = ArrayList(4) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) systemOSH = ObjectStateHolder('oraclesystem') systemOSH.setAttribute('data_name', client.getSid()) systemOSH.setAttribute('oraclesystem_dbaddress', client.getIpAddress()) modeling.setAppSystemVendor(systemOSH) webServerOSH = None nameToHostOSH = HashMap() hostToServerOSH = HashMap() hostToIpAddress = HashMap() databasesOSH = HashMap() resultSet = None try: objs = __assocWithSchemaName(['FND_OAM_APP_SYS_STATUS'], schemaName, viewSchemaName) # query a special table that holds Applications System Status related information resultSet = client.executeQuery( 'SELECT * FROM %s' % objs) #@@CMD_PERMISION sql protocol execution except: logger.debugException( 'SQL query failure. "SELECT * FROM FND_OAM_APP_SYS_STATUS"') Framework.reportWarning('No Oracle E-Business Suite components found.') if resultSet: OSHVResult.add(systemOSH) retOSHs.set(0, systemOSH) else: return None while resultSet.next(): name = resultSet.getString(1) dbSid = resultSet.getString(4) status = resultSet.getString(6) host = resultSet.getString(7) port = client.getPort() if logger.isDebugEnabled(): logger.debug('-----------------------------') logger.debug('name = ', name) logger.debug('status = ', status) if host != None: logger.debug('host = ', host) else: logger.debug('skipping Application system with None host') continue logger.debug('-----------------------------') hostOSH = nameToHostOSH.get(host) serverOSH = hostToServerOSH.get(host) hostIP = hostToIpAddress.get(host) if not hostIP: hostIP = netutils.getHostAddress(host, host) if hostOSH == None and netutils.isValidIp(hostIP): hostOSH = modeling.createHostOSH(hostIP) OSHVResult.add(hostOSH) nameToHostOSH.put(host, hostOSH) hostToIpAddress.put(host, hostIP) if hostOSH == None: logger.warn('Failed to created host [', host, ']') continue if serverOSH == None: serverOSH = modeling.createJ2EEServer('oracleias', hostIP, None, hostOSH, host) OSHVResult.add(serverOSH) hostToServerOSH.put(host, serverOSH) serverMemberOSH = modeling.createLinkOSH('member', systemOSH, serverOSH) OSHVResult.add(serverMemberOSH) if name.find('WEB_SERVER') == 0 and host != None: webServerOSH = serverOSH serverOSH.setBoolAttribute('oracleias_web', 1) elif name.find('FORMS_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_form', 1) elif name.find('ADMIN_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_admin', 1) elif name.find('CP_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_concurrentprocessing', 1) elif name.find('DATABASE') == 0 and host != None: dbOSH = modeling.createDatabaseOSH('oracle', dbSid, port, hostIP, hostOSH) OSHVResult.add(dbOSH) databasesOSH.put(dbSid, dbOSH) memberOSH = modeling.createLinkOSH('member', systemOSH, dbOSH) OSHVResult.add(memberOSH) resultSet.close() try: systemMetrics(client, systemOSH, webServerOSH, OSHVResult, schemaName, viewSchemaName) except: logger.debug("Failed to get system metrics") retOSHs.set(1, hostToServerOSH) retOSHs.set(2, nameToHostOSH) retOSHs.set(3, databasesOSH) return retOSHs
# Jython Dictionary dict = {'011': 'New Delhi', '022': 'Mumbai', '033': 'Kolkata', 'Age': 25} print("dict['011']: ", dict['011']) print("dict['Age']: ", dict['Age']) ######################################################################################################################## import java.util.ArrayList as ArrayList arr = ArrayList() arr.add(10) arr.add(20) print("ArrayList: ", arr) arr.remove(10) #remove 10 from arraylist arr.add(0, 5) #add 5 at 0th index print("ArrayList: ", arr) print("element at index 1:", arr.get(1)) #retrieve item at index 1 arr.set(0,100) #set item at 0th index to 100 print("ArrayList: ", arr) # Jarray Class from jarray import array my_seq = (1, 2, 3, 4, 5) arr1 = array(my_seq, 'i') print(arr1) myStr = "Hello Jython" arr2 = array(myStr, 'c') print(arr2)
class AssignmentIteratorImpl(AssignmentIterator): """ generated source for class AssignmentIteratorImpl """ sourceTupleIndices = None # This time we just have integers to deal with valueIndices = None nextAssignment = ArrayList() assignmentMap = HashMap() headOnly = False done = False plan = AssignmentIterationPlan() def __init__(self, plan): """ generated source for method __init__ """ super(AssignmentIteratorImpl, self).__init__() self.plan = plan # TODO: Handle this case with a separate class if plan.getVarsToAssign() == None: self.headOnly = True return # Set up source tuple... self.sourceTupleIndices = ArrayList(plan.getTuplesBySource().size()) i = 0 while i < plan.getTuplesBySource().size(): self.sourceTupleIndices.add(0) i += 1 # Set up... self.valueIndices = ArrayList(plan.getVarsToAssign().size()) i = 0 while i < plan.getVarsToAssign().size(): self.valueIndices.add(0) self.nextAssignment.add(None) i += 1 self.assignmentMap.putAll(plan.getHeadAssignment()) # Update "nextAssignment" according to the values of the # value indices updateNextAssignment() # Keep updating it until something really works makeNextAssignmentValid() def makeNextAssignmentValid(self): """ generated source for method makeNextAssignmentValid """ if self.nextAssignment == None: return # Something new that can pop up with functional constants... i = 0 while i < len(self.nextAssignment): if self.nextAssignment.get(i) == None: # Some function doesn't agree with the answer here # So what do we increment? incrementIndex(self.plan.getIndicesToChangeWhenNull().get(i)) if self.nextAssignment == None: return i = -1 i += 1 # Find all the unsatisfied distincts # Find the pair with the earliest var. that needs to be changed varsToChange = ArrayList() d = 0 while d < self.plan.getDistincts().size(): # The assignments must use the assignments implied by nextAssignment if term1 == term2: # need to change one of these varsToChange.add(self.plan.getVarsToChangePerDistinct().get(d)) d += 1 if not varsToChange.isEmpty(): # We want just the one, as it is a full restriction on its # own behalf changeOneInNext(Collections.singleton(varToChange)) def getLeftmostVar(self, vars): """ generated source for method getLeftmostVar """ for var in plan.getVarsToAssign(): if vars.contains(var): return var return None def replaceVariables(self, term): """ generated source for method replaceVariables """ if isinstance(term, (GdlFunction, )): raise RuntimeException("Function in the distinct... not handled") # Use the assignments implied by nextAssignment if self.plan.getHeadAssignment().containsKey(term): return self.plan.getHeadAssignment().get(term) # Translated in head assignment if isinstance(term, (GdlConstant, )): return term index = self.plan.getVarsToAssign().indexOf(term) return self.nextAssignment.get(index) def incrementIndex(self, index): """ generated source for method incrementIndex """ if index < 0: # Trash the iterator self.nextAssignment = None return if self.plan.getValuesToCompute() != None and self.plan.getValuesToCompute().containsKey(index): # The constant at this index is functionally computed self.incrementIndex(index - 1) return if self.plan.getSourceDefiningSlot().get(index) != -1: # This is set by a source; increment the source incrementSource(self.plan.getSourceDefiningSlot().get(index)) return # We try increasing the var at index by 1. # Everything to the right of it gets reset. # If it can't be increased, increase the number # to the left instead. If nothing can be # increased, trash the iterator. curValue = self.valueIndices.get(index) if curValue == self.plan.getValuesToIterate().get(index).size() - 1: self.incrementIndex(index - 1) return self.valueIndices.set(index, curValue + 1) i = index + 1 while i < len(self.valueIndices): pass i += 1 updateNextAssignment() def incrementSource(self, source): """ generated source for method incrementSource """ if source < 0: self.nextAssignment = None return curValue = self.sourceTupleIndices.get(source) if curValue == self.plan.getTuplesBySource().get(source).size() - 1: self.incrementSource(source - 1) return self.sourceTupleIndices.set(source, curValue + 1) i = source + 1 while i < len(self.sourceTupleIndices): pass i += 1 i = 0 while i < len(self.valueIndices): pass i += 1 updateNextAssignment() def updateNextAssignment(self): """ generated source for method updateNextAssignment """ s = 0 while s < len(self.sourceTupleIndices): if len(tuples) == 0: self.nextAssignment = None return while i < len(tuple_): if putDontCheck: self.nextAssignment.set(varSlotChosen, value) else: if not self.nextAssignment.get(varSlotChosen) == value: self.incrementSource(s) return i += 1 s += 1 i = 0 while i < len(self.valueIndices): if (self.plan.getValuesToCompute() == None or not self.plan.getValuesToCompute().containsKey(i)) and self.plan.getSourceDefiningSlot().get(i) == -1: self.nextAssignment.set(i, self.plan.getValuesToIterate().get(i).get(self.valueIndices.get(i))) elif self.plan.getSourceDefiningSlot().get(i) == -1: self.nextAssignment.set(i, valueFromFunction) i += 1 @overloaded def changeOneInNext(self, vars): """ generated source for method changeOneInNext """ if self.nextAssignment == None: return if vars.isEmpty(): if self.headOnly: self.done = True return else: self.done = True return if self.plan.getVarsToAssign() == None: print "headOnly: " + self.headOnly rightmostVar = getRightmostVar(vars) self.incrementIndex(self.plan.getVarsToAssign().indexOf(rightmostVar)) self.makeNextAssignmentValid() @changeOneInNext.register(object, Collection, Map) def changeOneInNext_0(self, varsToChange, assignment): """ generated source for method changeOneInNext_0 """ if self.nextAssignment == None: return for varToChange in varsToChange: if index != -1: if assignedValue == None: raise IllegalArgumentException("assignedValue is null; " + "varToChange is " + varToChange + " and assignment is " + assignment) if self.nextAssignment == None: raise IllegalStateException("nextAssignment is null") if not assignedValue == self.nextAssignment.get(index): return self.changeOneInNext(varsToChange) def hasNext(self): """ generated source for method hasNext """ if self.plan.getEmpty(): return False if self.headOnly: return (not self.plan.getAllDone() and not self.done) return (self.nextAssignment != None) def next(self): """ generated source for method next """ if self.headOnly: if self.plan.getAllDone() or self.done: raise RuntimeException("Asking for next when all done") self.done = True return self.plan.getHeadAssignment() updateMap() self.incrementIndex(len(self.valueIndices) - 1) self.makeNextAssignmentValid() return self.assignmentMap def updateMap(self): """ generated source for method updateMap """ i = 0 while i < self.plan.getVarsToAssign().size(): self.assignmentMap.put(self.plan.getVarsToAssign().get(i), self.nextAssignment.get(i)) i += 1 def getRightmostVar(self, vars): """ generated source for method getRightmostVar """ rightmostVar = None for var in plan.getVarsToAssign(): if vars.contains(var): rightmostVar = var return rightmostVar def remove(self): """ generated source for method remove """
def infrastructure(client, OSHVResult, Framework, schemaName = None, viewSchemaName = None): retOSHs = ArrayList(4) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) retOSHs.add(None) systemOSH = ObjectStateHolder('oraclesystem') systemOSH.setAttribute('data_name', client.getSid()) systemOSH.setAttribute('oraclesystem_dbaddress', client.getIpAddress()) modeling.setAppSystemVendor(systemOSH) webServerOSH = None nameToHostOSH = HashMap() hostToServerOSH = HashMap() hostToIpAddress = HashMap() databasesOSH = HashMap() resultSet = None try: objs = __assocWithSchemaName(['FND_OAM_APP_SYS_STATUS'], schemaName, viewSchemaName) # query a special table that holds Applications System Status related information resultSet = client.executeQuery('SELECT * FROM %s' % objs)#@@CMD_PERMISION sql protocol execution except: logger.debugException('SQL query failure. "SELECT * FROM FND_OAM_APP_SYS_STATUS"') Framework.reportWarning('No Oracle E-Business Suite components found.') if resultSet: OSHVResult.add(systemOSH) retOSHs.set(0, systemOSH) else: return None while resultSet.next(): name = resultSet.getString(1) dbSid = resultSet.getString(4) status = resultSet.getString(6) host = resultSet.getString(7) port = client.getPort() if logger.isDebugEnabled(): logger.debug('-----------------------------') logger.debug('name = ', name) logger.debug('status = ', status) if host != None: logger.debug('host = ', host) else: logger.debug('skipping Application system with None host') continue logger.debug('-----------------------------') hostOSH = nameToHostOSH.get(host) serverOSH = hostToServerOSH.get(host) hostIP = hostToIpAddress.get(host) if not hostIP: hostIP = netutils.getHostAddress(host, host) if hostOSH == None and netutils.isValidIp(hostIP): hostOSH = modeling.createHostOSH(hostIP) OSHVResult.add(hostOSH) nameToHostOSH.put(host,hostOSH) hostToIpAddress.put(host,hostIP) if hostOSH == None: logger.warn('Failed to created host [', host, ']') continue if serverOSH == None: serverOSH = modeling.createJ2EEServer('oracleias', hostIP, None, hostOSH, host) OSHVResult.add(serverOSH) hostToServerOSH.put(host,serverOSH) serverMemberOSH = modeling.createLinkOSH('member', systemOSH, serverOSH) OSHVResult.add(serverMemberOSH) if name.find('WEB_SERVER') == 0 and host != None: webServerOSH = serverOSH serverOSH.setBoolAttribute('oracleias_web', 1) elif name.find('FORMS_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_form', 1) elif name.find('ADMIN_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_admin', 1) elif name.find('CP_SERVER') == 0 and host != None: serverOSH.setBoolAttribute('oracleias_concurrentprocessing', 1) elif name.find('DATABASE') == 0 and host != None: dbOSH = modeling.createDatabaseOSH('oracle', dbSid, port, hostIP, hostOSH) OSHVResult.add(dbOSH) databasesOSH.put(dbSid,dbOSH) memberOSH = modeling.createLinkOSH('member', systemOSH, dbOSH) OSHVResult.add(memberOSH) resultSet.close() try: systemMetrics(client,systemOSH,webServerOSH, OSHVResult, schemaName, viewSchemaName) except: logger.debug("Failed to get system metrics") retOSHs.set(1, hostToServerOSH) retOSHs.set(2, nameToHostOSH) retOSHs.set(3, databasesOSH) return retOSHs