From: <de...@us...> - 2004-01-16 00:51:34
|
Update of /cvsroot/pymerase/pymerase/pymerase/output In directory sc8-pr-cvs1:/tmp/cvs-serv2385 Modified Files: CreateJava.py Log Message: more progress at converting squashed sigmoid velocity templates Index: CreateJava.py =================================================================== RCS file: /cvsroot/pymerase/pymerase/pymerase/output/CreateJava.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CreateJava.py 18 Dec 2003 00:32:03 -0000 1.1 --- CreateJava.py 16 Jan 2004 00:51:30 -0000 1.2 *************** *** 90,97 **** class JavaTemplate(Template): ! def __init__(self): Template.__init__(self) ####################################### # Output Translater Interface --- 90,134 ---- class JavaTemplate(Template): ! def __init__(self, classMetaInfo, TranslatorName): Template.__init__(self) + self.classMetaInfo = classMetaInfo + self.TranslatorName = TranslatorName + def ClassName(self): + return self.classMetaInfo.getName(self.TranslatorName) + + def ExtendsClause(self): + if not self.classMetaInfo.isRootClass(): + baseClasses = self.classMetaInfo.getBaseClassNames(self.TranslatorName) + return "extends " + string.join(baseClasses, ", ") + else: + return "" + + def writeDebugPrint(self, indent): + c =[] + c +=['/**'] + c +=[' * Prints a string represenation of this class to aid in debugging'] + c +=[' */'] + c +=['public void debugPrint()'] + c +=['{'] + c +=[' System.out.println("class %(ClassName())s");' % (self)] + c +=[' debugDumpAttributes();'] + c +=[' System.out.println();'] + c +=['}'] + c +=[''] + c +=[''] + c +=['protected void debugDumpAttributes()'] + c +=['{'] + if not self.classMetaInfo.isRootClass(): + c +=[' super.debugDumpAttributes();'] + else: + c +=[' System.out.println(" _id: " + _id);'] + for attribute in self.classMetaInfo.getAttributes(): + name = attribute.getName(self.TranslatorName) + c +=[' System.out.println(" '+name+': " +'+ name + ');'] + c += ['}'] + return string.join(addIndentToStrings(indent, c), os.linesep) + ####################################### # Output Translater Interface *************** *** 100,142 **** """ c = [] ! c += ["/** "] ! c += [" * Create a new %(ClassName)s"] ! c += [" *"] ! c += [" * All collections will be initialized (as empty)."] ! c += [" */"] ! c += [""] ! c += ["public %(ClassName)s()"] ! c += ["{"] ! if not classMetaInfo.isBaseClass(): ! c += [" super();"] ! c += [""] ! c += ["%(ClasInitializer)s"] ! c += [""] ! c += ["/**"] ! c += [" * Create a new %(ClassName)s with all fields initialized."] ! c += [" */"] ! c += ["%(DefaultConstructor)s"] ! c += [""] ! c += ["/**"] ! c += [" * Prints a string represenation of this class to aid in deubbing"] ! c += [" */"] ! c += ["public void debugPrint()"] ! c += ["{"] ! c += [" System.out.println(class %(ClassName)s)"] ! c += [" debugDumpAttributes();"] ! c += [" System.out.println();"] ! c += ["}"] ! c += [""] ! c += ["protected void de"] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] ! c += [""] --- 137,204 ---- """ c = [] ! c += ['/** '] ! c += [' * Create a new %(ClassName())s'] ! c += [' *'] ! c += [' * All collections will be initialized (as empty).'] ! c += [' */'] ! c += [''] ! c += ['public %(ClassName())s %(ExtendsClause())s'] ! c += ['{'] ! c += [' #writeNoArgCtor'] ! if len(classMetaInfo.getAttributes()) > 0: ! c += [' #writeArgCtor'] ! c +=[''] ! c +=[' /**'] ! c +=[' * Getter / Setter Pairs'] ! c +=[' */'] ! c +=[''] ! c +=[''] ! c +=[' /**'] ! c +=[' * Collection adder/removers'] ! c +=[' */'] ! c +=[''] ! c +=[''] ! c +=[' /**'] ! c +=[' * Debugging'] ! c +=[' */'] ! c +=['%(writeDebugPrint(2))s'] ! c +=[''] ! c +=[' /**'] ! c +=[' * Attributes'] ! c +=[' */ '] ! #for attribute in classMetaInfo.getAttributes(): ! # c += [' %()'] ! c +=[''] ! c +=[' /**'] ! c +=[' * Extra attributes to hold the primary key of the different object'] ! c +=[' * references.'] ! c +=[' */'] ! c +=[''] ! c +=[''] ! c +=[' /**'] ! c +=[' * Extra Object Relational Bridge (OJB) attributes for mapping back'] ! c +=[' * to classses which have a 1:N relation with this specific class.'] ! c +=[' */'] ! c +=[''] ! c +=[''] ! c +=[' /**'] ! c +=[' * Primary Key in database'] ! c +=[' */ '] ! #c +=[' protected int _id;'] ! c +=['};'] ! ! template_engine = JavaTemplate(classMetaInfo, None) ! ! template = string.join(c, os.linesep) ! destination_filename = os.path.join(destination, ! template_engine.ClassName()+".java") ! template_engine.writeFile(template, destination_filename) ! return ! ! c += ['/**'] ! c += [' * Create a new %(ClassName)s with all fields initialized.'] ! c += [' */'] ! c += ['%(DefaultConstructor)s'] ! c += [''] *************** *** 147,158 **** os.mkdir(destination) elif not os.path.isdir(destination): ! msg = "PATH(%s) is not a directory!" % (destination) raise ValueError(msg) package_information = [] ! for t in tables: try: ! package_information.append(writeClass(destination, t)) except NotImplementedError, e: ! warn("Skipping %s" % ( t.getName() ), DebugWarning) --- 209,220 ---- os.mkdir(destination) elif not os.path.isdir(destination): ! msg = 'PATH(%s) is not a directory!' % (destination) raise ValueError(msg) package_information = [] ! for class_info in parsedInput: try: ! package_information.append(writeClass(destination, class_info)) except NotImplementedError, e: ! warn('Skipping %s' % ( t.getName() ), DebugWarning) |