def __resolveRecordReferenceNodes(self): nodeFilter = DepthFirstNodeFilter( filterType=UnresolvedRecordReferenceNode) for unresolvedRecordReferenceNode in nodeFilter.getAll(self.__astRoot): parent = unresolvedRecordReferenceNode.getParent() fqName = unresolvedRecordReferenceNode.getAttribute("type") recordSequenceNode = self.__astRoot.getSpecification( ).getRecordSequences().getRecordSequence(fqName) if not recordSequenceNode: message = "Cannot resolve record reference for record of type `%s`" % ( fqName) self.__log.error(message) raise RuntimeError(message) recordTypeNode = recordSequenceNode.getRecordType() resolvedRecordReferenceNode = ResolvedRecordReferenceNode() resolvedRecordReferenceNode.setAttribute( 'name', unresolvedRecordReferenceNode.getAttribute("name")) resolvedRecordReferenceNode.setAttribute( 'type', StringTransformer.ucFirst( StringTransformer.us2cc( unresolvedRecordReferenceNode.getAttribute("type")))) resolvedRecordReferenceNode.setRecordTypeRef(recordTypeNode) resolvedRecordReferenceNode.orderkey = unresolvedRecordReferenceNode.orderkey parent.setReference(resolvedRecordReferenceNode)
def __setterFactory(self, setterXMLNode): t = setterXMLNode.prop("type") k = setterXMLNode.prop("key") setterNode = None for cls in AstUtils.iterSubClasses(AbstractSetterNode): try: args, kwargs = cls.parseType(t) kwargs.update(key=k) kwargs.update(type_alias="%sType" % StringTransformer.us2ccAll(k)) setterNode = cls(*args, **kwargs) break except ParseTypeError: pass if setterNode is None: raise RuntimeError( 'Unexpected setter type `%s` for setter `%s` (expected one of `(field|reference)_setter`)' % (t, k)) # recursively read range provider arguments ArgumentReader.readArguments(setterXMLNode, setterNode) return setterNode
def __resolveRecordReferenceNodes(self): nodeFilter = DepthFirstNodeFilter(filterType=UnresolvedRecordReferenceNode) for unresolvedRecordReferenceNode in nodeFilter.getAll(self.__astRoot): parent = unresolvedRecordReferenceNode.getParent() fqName = unresolvedRecordReferenceNode.getAttribute("type") recordSequenceNode = self.__astRoot.getSpecification().getRecordSequences().getRecordSequence(fqName) if not recordSequenceNode: message = "Cannot resolve record reference for record of type `%s`" % (fqName) self.__log.error(message) raise RuntimeError(message) recordTypeNode = recordSequenceNode.getRecordType() resolvedRecordReferenceNode = ResolvedRecordReferenceNode() resolvedRecordReferenceNode.setAttribute('name', unresolvedRecordReferenceNode.getAttribute("name")) resolvedRecordReferenceNode.setAttribute('type', StringTransformer.ucFirst(StringTransformer.us2cc(unresolvedRecordReferenceNode.getAttribute("type")))) resolvedRecordReferenceNode.setRecordTypeRef(recordTypeNode) resolvedRecordReferenceNode.orderkey = unresolvedRecordReferenceNode.orderkey parent.setReference(resolvedRecordReferenceNode)
def __setterFactory(self, setterXMLNode): t = setterXMLNode.prop("type") k = setterXMLNode.prop("key") setterNode = None for cls in AstUtils.iterSubClasses(AbstractSetterNode): try: args, kwargs = cls.parseType(t) kwargs.update(key=k) kwargs.update(type_alias="%sType" % StringTransformer.us2ccAll(k)) setterNode = cls(*args, **kwargs) break except ParseTypeError: pass if setterNode is None: raise RuntimeError('Unexpected setter type `%s` for setter `%s` (expected one of `(field|reference)_setter`)' % (t, k)) # recursively read range provider arguments ArgumentReader.readArguments(setterXMLNode, setterNode) return setterNode