def get(self): SEP = self.config.separator TAB = self.config.tabulation out = "" + SEP clazz = util.name_to_camelcase(self.name, "_") out += "class " + clazz + "(models.Model):" + SEP for one in self.columns: out += TAB + Column(one).get() + SEP return out
def get(self, deps): SEP = self.config.separator TAB = self.config.tabulation out = ''+SEP clazz = util.name_to_camelcase(self.name, '_') out += 'class '+clazz+'(Base):'+SEP out += TAB+'__tablename__ = \''+self.name+'\''+SEP out += TAB+SEP for one in self.columns: out += TAB+Column(one).get()+SEP if deps.has_key(self.name): dependencies = deps.get(self.name) for one in dependencies: out += SEP out += TAB name = util.name_to_camelcase(one, '_') out += one+' = relationship(\''+name+'\', lazy=\'subquery\')' out += SEP return out
def get(self): clazz = util.name_to_camelcase(self.name, "_") SEP = self.config.separator out = "" out += "/**" + SEP out += "* @author craft generated" + SEP out += "*/" + SEP out += "@Entity" + SEP out += '@Table( name="' + self.name + '")' + SEP out += "public class " + clazz + " implements Serializable {" + SEP out += SEP for one in self.columns: out += Column(one, self.config).get() for one in self.columns: out += Column(one, self.config).getset() return out
def generate(self, output): package = self.config.orm["package"] dir = os.sep.join(package.split(".")) for one in self.structure.tables: clazz = util.name_to_camelcase(one.name, "_") filename = dir + os.sep + clazz + ".java" code = base.GeneratorOutputFile(filename) code.data += self.file_header(package) code.data += Table(one, self.config).get() code.data += "}" + self.config.separator output.orm.append(code)