diff --git a/src/codefile/aggregator.py b/src/codefile/aggregator.py index 6355a7d..a263275 100644 --- a/src/codefile/aggregator.py +++ b/src/codefile/aggregator.py @@ -7,6 +7,7 @@ import {pack_model}.{class_name}; + public class {class_name}Aggregator {{ {indent}private {class_name} {varname}; {indent} @@ -14,7 +15,7 @@ {indent}{indent}return this.{varname}; {indent}}} {indent} -{indent}public void set{class_name}({class_name} {varname}) {{ +{indent}public void set{class_name}(final {class_name} {varname}) {{ {indent}{indent}this.{varname} = {varname}; {indent}}} }} @@ -33,4 +34,3 @@ def write(config): ) util.writeToFile(config.data_dir, config.pack_aggregator, config.class_name + "Aggregator.java", aggregator) - diff --git a/src/codefile/model.py b/src/codefile/model.py index f14fa06..3ff9055 100644 --- a/src/codefile/model.py +++ b/src/codefile/model.py @@ -10,7 +10,7 @@ public class {class_name} {{""" ) -model_end = "}\n\n" +model_end = "}\n" field_col_tpl = "{indent}private {type} {name};" @@ -23,7 +23,7 @@ ) setter_col_tpl = ( -"""{indent}public void set{methname}({type} {name}) {{ +"""{indent}public void set{methname}(final {type} {name}) {{ {indent}{indent}this.{name} = {name}; {indent}}} {indent} @@ -80,4 +80,3 @@ def write(config): ) util.writeToFile(config.data_dir, config.pack_model, config.class_name + ".java", model) - diff --git a/src/codefile/repository.py b/src/codefile/repository.py index e14b414..d3fc0c4 100644 --- a/src/codefile/repository.py +++ b/src/codefile/repository.py @@ -20,6 +20,7 @@ import {pack_model}.{class_name}; import {pack_utility}.Sql2oUtility; + @Repository public class {class_name}RepositoryImpl implements {class_name}Repository {{ {indent}private final static Logger logger = LoggerFactory.getLogger({class_name}Repository.class); @@ -27,13 +28,13 @@ {indent}@Autowired {indent}private Sql2o sql2o; {indent} -{indent}private static String getSelectBase(List fields_to_ignore) {{ +{indent}private static String getSelectBase(final List fields_to_ignore) {{ {select_fields} {indent}{indent}return res; {indent}}} {indent} {indent}@Override -{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore, Connection con) {{ +{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, final List fields_to_ignore, final Connection con) {{ {indent}{indent}logger.debug("DB>> {select_methods_prefix}By{methid}() - {idslog}); {indent}{indent} {indent}{indent}String sql = "select " + {class_name}RepositoryImpl.getSelectBase(fields_to_ignore) + "from {table_name} {initial} "; @@ -51,13 +52,13 @@ {indent}}} {indent} {indent}@Override -{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, Connection con) {{ -{indent}{indent}return {select_methods_prefix}By{methid}({idslist}, null, con); +{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, final Connection con) {{ +{indent}{indent}return this.{select_methods_prefix}By{methid}({idslist}, null, con); {indent}}} {indent} {indent}@Override -{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore) {{ -{indent}{indent}try (Connection con = sql2o.open()) {{ +{indent}public {class_name} {select_methods_prefix}By{methid}({idsfirm}, final List fields_to_ignore) {{ +{indent}{indent}try (Connection con = this.sql2o.open()) {{ {indent}{indent}{indent}return this.{select_methods_prefix}By{methid}({idslist}, fields_to_ignore, con); {indent}{indent}}} {indent}}} @@ -68,10 +69,10 @@ {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}All(List fields_to_ignore, Connection con) {{ +{indent}public List<{class_name}> {select_methods_prefix}All(final List fields_to_ignore, final Connection con) {{ {indent}{indent}logger.debug("DB>> {select_methods_prefix}All()"); {indent}{indent} -{indent}{indent}String sql = "select " + {class_name}RepositoryImpl.getSelectBase(fields_to_ignore) + "from {table_name} {initial} "; +{indent}{indent}final String sql = "select " + {class_name}RepositoryImpl.getSelectBase(fields_to_ignore) + "from {table_name} {initial} "; {indent}{indent} {indent}{indent}List<{class_name}> res; {indent}{indent} @@ -84,24 +85,24 @@ {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}All(Connection con) {{ -{indent}{indent}return {select_methods_prefix}All(null, con); +{indent}public List<{class_name}> {select_methods_prefix}All(final Connection con) {{ +{indent}{indent}return this.{select_methods_prefix}All(null, con); {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}All(List fields_to_ignore) {{ -{indent}{indent}try (Connection con = sql2o.open()) {{ +{indent}public List<{class_name}> {select_methods_prefix}All(final List fields_to_ignore) {{ +{indent}{indent}try (Connection con = this.sql2o.open()) {{ {indent}{indent}{indent}return this.{select_methods_prefix}All(fields_to_ignore, con); {indent}{indent}}} {indent}}} {indent} {indent}@Override {indent}public List<{class_name}> {select_methods_prefix}All() {{ -{indent}{indent}return {select_methods_prefix}All((List) null); +{indent}{indent}return this.{select_methods_prefix}All((List) null); {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}ByModel({class_name} {varname}, List fields_to_ignore, Connection con) {{ +{indent}public List<{class_name}> {select_methods_prefix}ByModel(final {class_name} {varname}, final List fields_to_ignore, final Connection con) {{ {indent}{indent}logger.debug("DB>> {select_methods_prefix}ByModel()"); {indent}{indent} {indent}{indent}String sql = "select " + {class_name}RepositoryImpl.getSelectBase(fields_to_ignore) + "from {table_name} {initial} "; @@ -122,27 +123,27 @@ {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}ByModel({class_name} {varname}, Connection con) {{ -{indent}{indent}return {select_methods_prefix}ByModel({varname}, null, con); +{indent}public List<{class_name}> {select_methods_prefix}ByModel(final {class_name} {varname}, final Connection con) {{ +{indent}{indent}return this.{select_methods_prefix}ByModel({varname}, null, con); {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}ByModel({class_name} {varname}, List fields_to_ignore) {{ -{indent}{indent}try (Connection con = sql2o.open()) {{ +{indent}public List<{class_name}> {select_methods_prefix}ByModel(final {class_name} {varname}, final List fields_to_ignore) {{ +{indent}{indent}try (Connection con = this.sql2o.open()) {{ {indent}{indent}{indent}return this.{select_methods_prefix}ByModel({varname}, fields_to_ignore, con); {indent}{indent}}} {indent}}} {indent} {indent}@Override -{indent}public List<{class_name}> {select_methods_prefix}ByModel({class_name} {varname}) {{ -{indent}{indent}return {select_methods_prefix}ByModel({varname}, (List) null); +{indent}public List<{class_name}> {select_methods_prefix}ByModel(final {class_name} {varname}) {{ +{indent}{indent}return this.{select_methods_prefix}ByModel({varname}, (List) null); {indent}}} {indent} {indent}@Override -{indent}public {class_name} insert({class_name} {varname}, Connection con) {{ +{indent}public {class_name} insert(final {class_name} {varname}, final Connection con) {{ {indent}{indent}logger.info("DB>> insert()"); {indent}{indent} -{indent}{indent}String sql = ( +{indent}{indent}final String sql = ( {indent}{indent}{indent}"insert into {table_name} ( " + {insert_fields} {indent}{indent}{indent}") " + @@ -164,19 +165,19 @@ {indent}}} {indent} {indent}@Override -{indent}public {class_name} insert({class_name} {varname}) {{ -{indent}{indent}try (Connection con = sql2o.beginTransaction()) {{ -{indent}{indent}{indent}{varname} = this.insert({varname}, con); +{indent}public {class_name} insert(final {class_name} {varname}) {{ +{indent}{indent}try (Connection con = this.sql2o.beginTransaction()) {{ +{indent}{indent}{indent}final {class_name} {varname}2 = this.insert({varname}, con); {indent}{indent}{indent}con.commit(); -{indent}{indent}{indent}return {varname}; +{indent}{indent}{indent}return {varname}2; {indent}{indent}}} {indent}}} {indent} {update} {indent}@Override -{indent}public {class_name} save({class_name} {varname}, Connection con) {{ +{indent}public {class_name} save(final {class_name} {varname}, final Connection con) {{ {idsinit} -{indent}{indent}{class_name} {varname}2 = this.{select_methods_prefix}By{methid}({idslist}, null, con); +{indent}{indent}final {class_name} {varname}2 = this.{select_methods_prefix}By{methid}({idslist}, null, con); {indent}{indent} {indent}{indent}if ({varname}2 == null) {{ {indent}{indent}{indent}return this.insert({varname}, con); @@ -185,16 +186,16 @@ {indent}}} {indent} {indent}@Override -{indent}public {class_name} save({class_name} {varname}) {{ -{indent}{indent}try (Connection con = sql2o.beginTransaction()) {{ -{indent}{indent}{indent}{class_name} res = this.save({varname}, con); +{indent}public {class_name} save(final {class_name} {varname}) {{ +{indent}{indent}try (Connection con = this.sql2o.beginTransaction()) {{ +{indent}{indent}{indent}final {class_name} res = this.save({varname}, con); {indent}{indent}{indent}con.commit(); {indent}{indent}{indent}return res; {indent}{indent}}} {indent}}} {indent} {indent}@Override -{indent}public void delete({idsfirm}, Connection con) {{ +{indent}public void delete({idsfirm}, final Connection con) {{ {indent}{indent}logger.info("DB>> delete() - {idslog}); {indent}{indent} {indent}{indent}String sql = "delete from {table_name} "; @@ -210,14 +211,14 @@ {indent} {indent}@Override {indent}public void delete({idsfirm}) {{ -{indent}{indent}try (Connection con = sql2o.beginTransaction()) {{ +{indent}{indent}try (Connection con = this.sql2o.beginTransaction()) {{ {indent}{indent}{indent}this.delete({idslist}, con); {indent}{indent}{indent}con.commit(); {indent}{indent}}} {indent}}} {indent} {indent}@Override -{indent}public void deleteByModel({class_name} {varname}, Connection con) {{ +{indent}public void deleteByModel(final {class_name} {varname}, final Connection con) {{ {indent}{indent}logger.info("DB>> deleteByModel()"); {indent}{indent} {indent}{indent}String sql = "delete from {table_name} "; @@ -235,8 +236,8 @@ {indent}}} {indent} {indent}@Override -{indent}public void deleteByModel({class_name} {varname}) {{ -{indent}{indent}try (Connection con = sql2o.beginTransaction()) {{ +{indent}public void deleteByModel(final {class_name} {varname}) {{ +{indent}{indent}try (Connection con = this.sql2o.beginTransaction()) {{ {indent}{indent}{indent}this.deleteByModel({varname}, con); {indent}{indent}{indent}con.commit(); {indent}{indent}}} @@ -251,7 +252,7 @@ """ {indent}{indent} {indent}{indent}Object res_true; -{indent}{indent}Class klass = {id_col_type}.class; +{indent}{indent}final Class klass = {id_col_type}.class; {indent}{indent} {indent}{indent}if (res != null && (klass == Long.class || klass == BigDecimal.class)) {{ {indent}{indent}{indent}res_true = ((BigDecimal) res).longValue(); @@ -265,7 +266,7 @@ update_tpl = ( """{indent}@Override -{indent}public {class_name} update({class_name} {varname}, boolean exclude_nulls, Connection con) {{ +{indent}public {class_name} update(final {class_name} {varname}, final boolean exclude_nulls, final Connection con) {{ {indent}{indent}logger.info("DB>> update() - {idslog_update}); {indent}{indent} {indent}{indent}String sql = "update {table_name} set "; @@ -284,11 +285,11 @@ {indent}}} {indent} {indent}@Override -{indent}public {class_name} update({class_name} {varname}, boolean exclude_nulls) {{ -{indent}{indent}try (Connection con = sql2o.beginTransaction()) {{ -{indent}{indent}{indent}{varname} = this.update({varname}, exclude_nulls, con); +{indent}public {class_name} update(final {class_name} {varname}, final boolean exclude_nulls) {{ +{indent}{indent}try (Connection con = this.sql2o.beginTransaction()) {{ +{indent}{indent}{indent}final {class_name} {varname}2 = this.update({varname}, exclude_nulls, con); {indent}{indent}{indent}con.commit(); -{indent}{indent}{indent}return {varname}; +{indent}{indent}{indent}return {varname}2; {indent}{indent}}} {indent}}} {indent}""" @@ -296,12 +297,12 @@ idkey_mssql_tpl = "{indent}{indent}Object res = key;" -idkey_oracle_tpl = """{indent}{indent}Object res = Sql2oUtility.getInsertedId("{table_name}", "{id0}", con, key, {id_col_type}.class);""" +idkey_oracle_tpl = """{indent}{indent}final Object res = Sql2oUtility.getInsertedId("{table_name}", "{id0}", con, key, {id_col_type}.class);""" select_fields_tpl = ( """{indent}{indent}String res = ""; {indent}{indent} -{indent}{indent}fields_to_ignore = fields_to_ignore +{indent}{indent}final List fields_to_ignore_true = fields_to_ignore {indent}{indent}{indent}.stream() {indent}{indent}{indent}.map(field -> field.toUpperCase()) {indent}{indent}{indent}.collect(Collectors.toList()); @@ -310,7 +311,7 @@ ) select_field_col_tpl = ( -"""{indent}{indent}if (fields_to_ignore != null && ! fields_to_ignore.contains("{col}")) {{ +"""{indent}{indent}if (fields_to_ignore_true != null && ! fields_to_ignore_true.contains("{col}")) {{ {indent}{indent}{indent}res += "{initial}.{col}, "; {indent}{indent}}} {indent}{indent} @@ -335,7 +336,7 @@ bymodel_where_col_tpl = ( """{indent}{indent}if ({varname}.get{methcol}() != null) {{ -{indent}{indent}{indent} sql += "{col} = :{colname} and "; +{indent}{indent}{indent}sql += "{col} = :{colname} and "; {indent}{indent}}} {indent}{indent} """ @@ -343,7 +344,7 @@ update_fields_col_tpl = ( """{indent}{indent}if (! exclude_nulls || {varname}.get{methcol}() != null) {{ -{indent}{indent}{indent} sql += "{col} = :{colname}, "; +{indent}{indent}{indent}sql += "{col} = :{colname}, "; {indent}{indent}}} {indent}{indent} """ @@ -358,7 +359,7 @@ idslog_col_tpl = '{varid}: " + {varid} + "' idslog_update_col_tpl = '{varid}: " + {varname}.get{methid}() + "' idswhere_col_tpl = '{indent}{indent}sql += "{id} = :{varid} and "; \n' -idsinit_col_tpl = '{indent}{indent}{col_type} {varid} = {varname}.get{methid}();\n' +idsinit_col_tpl = '{indent}{indent}final {col_type} {varid} = {varname}.get{methid}();\n' idsparams_col_tpl = '{indent}{indent}{indent}query.addParameter("{varid}", {varid});\n' insert_params_tpl = '{indent}{indent}{indent}query.bind({varname});\n' insert_fields_col_tpl = '{indent}{indent}{indent}{indent}"{col}, " + \n' diff --git a/src/codefile/repository_interface.py b/src/codefile/repository_interface.py index eb3ee35..29c974a 100644 --- a/src/codefile/repository_interface.py +++ b/src/codefile/repository_interface.py @@ -11,6 +11,7 @@ import {pack_model}.{class_name}; + public interface {class_name}Repository {{ {indent}{class_name} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore, Connection con); {indent} @@ -84,4 +85,3 @@ def write(config): ) util.writeToFile(config.data_dir, config.pack_repo, config.class_name + "Repository.java", repoint) - diff --git a/src/codefile/service.py b/src/codefile/service.py index 185531d..9dac801 100644 --- a/src/codefile/service.py +++ b/src/codefile/service.py @@ -22,7 +22,7 @@ {indent}@Autowired {indent}private {class_name}Repository {varname}Repository; {indent} -{indent}private static {aggregator_class} enrich({class_name} {varname}) {{ +{indent}private static {aggregator_class} enrich(final {class_name} {varname}) {{ {indent}{indent}{aggregator_class} {aggregator_var} = null; {indent}{indent} {indent}{indent}if ({varname} != null) {{ @@ -34,141 +34,141 @@ {indent}{indent}return {aggregator_var}; {indent}}} {indent} -{indent}private static List<{aggregator_class}> enrich(List<{class_name}> {varname}s) {{ -{indent}{indent}List<{aggregator_class}> {aggregator_var}s = new ArrayList<>(); +{indent}private static List<{aggregator_class}> enrich(final List<{class_name}> {varname}s) {{ +{indent}{indent}final List<{aggregator_class}> {aggregator_var}s = new ArrayList<>(); {indent}{indent} {indent}{indent}if ({varname}s != null) {{ -{indent}{indent}{indent}for ({class_name} {varname}: {varname}s) {{ +{indent}{indent}{indent}for (final {class_name} {varname}: {varname}s) {{ {indent}{indent}{indent}{indent}{aggregator_var}s.add({class_name}ServiceImpl.enrich({varname})); {indent}{indent}{indent}}} {indent}{indent}}} {indent}{indent} -{indent}{indent} return {aggregator_var}s; +{indent}{indent}return {aggregator_var}s; {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}All(List fields_to_ignore, Connection con) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}All(fields_to_ignore, con); +{indent}public List<{aggregator_class}> {select_methods_prefix}All(final List fields_to_ignore, final Connection con) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}All(fields_to_ignore, con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}All(Connection con) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}All(con); +{indent}public List<{aggregator_class}> {select_methods_prefix}All(final Connection con) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}All(con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}All(List fields_to_ignore) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}All(fields_to_ignore); +{indent}public List<{aggregator_class}> {select_methods_prefix}All(final List fields_to_ignore) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}All(fields_to_ignore); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override {indent}public List<{aggregator_class}> {select_methods_prefix}All() {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}All(); +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}All(); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel({class_name} {varname}, List fields_to_ignore, Connection con) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}ByModel({varname}, fields_to_ignore, con); +{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel(final {class_name} {varname}, final List fields_to_ignore, final Connection con) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}ByModel({varname}, fields_to_ignore, con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel({class_name} {varname}, Connection con) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}ByModel({varname}, con); +{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel(final {class_name} {varname}, final Connection con) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}ByModel({varname}, con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel({class_name} {varname}, List fields_to_ignore) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}ByModel({varname}, fields_to_ignore); +{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel(final {class_name} {varname}, final List fields_to_ignore) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}ByModel({varname}, fields_to_ignore); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel({class_name} {varname}) {{ -{indent}{indent}List<{class_name}> {varname}s = {varname}Repository.{select_methods_prefix}ByModel({varname}); +{indent}public List<{aggregator_class}> {select_methods_prefix}ByModel(final {class_name} {varname}) {{ +{indent}{indent}final List<{class_name}> {varname}s = this.{varname}Repository.{select_methods_prefix}ByModel({varname}); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}s); {indent}}} {indent} {indent}@Override -{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore, Connection con) {{ -{indent}{indent}{class_name} {varname} = {varname}Repository.{select_methods_prefix}By{methid}({idslist}, fields_to_ignore, con); +{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, final List fields_to_ignore, final Connection con) {{ +{indent}{indent}final {class_name} {varname} = this.{varname}Repository.{select_methods_prefix}By{methid}({idslist}, fields_to_ignore, con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}); {indent}}} {indent} {indent}@Override -{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, Connection con) {{ -{indent}{indent}{class_name} {varname} = {varname}Repository.{select_methods_prefix}By{methid}({idslist}, con); +{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, final Connection con) {{ +{indent}{indent}final {class_name} {varname} = this.{varname}Repository.{select_methods_prefix}By{methid}({idslist}, con); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}); {indent}}} {indent} {indent}@Override -{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore) {{ -{indent}{indent}{class_name} {varname} = {varname}Repository.{select_methods_prefix}By{methid}({idslist}, fields_to_ignore); +{indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, final List fields_to_ignore) {{ +{indent}{indent}final {class_name} {varname} = this.{varname}Repository.{select_methods_prefix}By{methid}({idslist}, fields_to_ignore); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}); {indent}}} {indent} {indent}@Override {indent}public {aggregator_class} {select_methods_prefix}By{methid}({idsfirm}) {{ -{indent}{indent}{class_name} {varname} = {varname}Repository.{select_methods_prefix}By{methid}({idslist}); +{indent}{indent}final {class_name} {varname} = this.{varname}Repository.{select_methods_prefix}By{methid}({idslist}); {indent}{indent} {indent}{indent}return {class_name}ServiceImpl.enrich({varname}); {indent}}} {indent} {indent}@Override -{indent}public {class_name} insert({class_name} {varname}, Connection con) {{ -{indent}{indent}return {varname}Repository.insert({varname}, con); +{indent}public {class_name} insert(final {class_name} {varname}, final Connection con) {{ +{indent}{indent}return this.{varname}Repository.insert({varname}, con); {indent}}} {indent} {indent}@Override -{indent}public {class_name} insert({class_name} {varname}) {{ -{indent}{indent}return {varname}Repository.insert({varname}); +{indent}public {class_name} insert(final {class_name} {varname}) {{ +{indent}{indent}return this.{varname}Repository.insert({varname}); {indent}}} {update} {indent} {indent}@Override -{indent}public {class_name} save({class_name} {varname}, Connection con) {{ -{indent}{indent}return {varname}Repository.save({varname}, con); +{indent}public {class_name} save(final {class_name} {varname}, final Connection con) {{ +{indent}{indent}return this.{varname}Repository.save({varname}, con); {indent}}} {indent} {indent}@Override -{indent}public {class_name} save({class_name} {varname}) {{ -{indent}{indent}return {varname}Repository.save({varname}); +{indent}public {class_name} save(final {class_name} {varname}) {{ +{indent}{indent}return this.{varname}Repository.save({varname}); {indent}}} {indent} {indent}@Override -{indent}public void delete({idsfirm}, Connection con) {{ -{indent}{indent}{varname}Repository.delete({idslist}, con); +{indent}public void delete({idsfirm}, final Connection con) {{ +{indent}{indent}this.{varname}Repository.delete({idslist}, con); {indent}}} {indent} {indent}@Override {indent}public void delete({idsfirm}) {{ -{indent}{indent}{varname}Repository.delete({idslist}); +{indent}{indent}this.{varname}Repository.delete({idslist}); {indent}}} {indent} {indent}@Override -{indent}public void deleteByModel({class_name} {varname}, Connection con) {{ -{indent}{indent}{varname}Repository.deleteByModel({varname}, con); +{indent}public void deleteByModel(final {class_name} {varname}, final Connection con) {{ +{indent}{indent}this.{varname}Repository.deleteByModel({varname}, con); {indent}}} {indent} {indent}@Override -{indent}public void deleteByModel({class_name} {varname}) {{ -{indent}{indent}{varname}Repository.deleteByModel({varname}); +{indent}public void deleteByModel(final {class_name} {varname}) {{ +{indent}{indent}this.{varname}Repository.deleteByModel({varname}); {indent}}} }} """ @@ -177,13 +177,13 @@ update_tpl = ( """{indent} {indent}@Override -{indent}public {class_name} update({class_name} {varname}, boolean exclude_nulls, Connection con) {{ -{indent}{indent}return {varname}Repository.update({varname}, exclude_nulls, con); +{indent}public {class_name} update(final {class_name} {varname}, final boolean exclude_nulls, final Connection con) {{ +{indent}{indent}return this.{varname}Repository.update({varname}, exclude_nulls, con); {indent}}} {indent} {indent}@Override -{indent}public {class_name} update({class_name} {varname}, boolean exclude_nulls) {{ -{indent}{indent}return {varname}Repository.update({varname}, exclude_nulls); +{indent}public {class_name} update(final {class_name} {varname}, final boolean exclude_nulls) {{ +{indent}{indent}return this.{varname}Repository.update({varname}, exclude_nulls); {indent}}}""" ) diff --git a/src/codefile/service_interface.py b/src/codefile/service_interface.py index fb6c31d..23334f4 100644 --- a/src/codefile/service_interface.py +++ b/src/codefile/service_interface.py @@ -12,6 +12,7 @@ import {pack_aggregator}.{aggregator_class}; import {pack_model}.{class_name}; + public interface {class_name}Service {{ {indent}{aggregator_class} {select_methods_prefix}By{methid}({idsfirm}, List fields_to_ignore, Connection con); {indent} @@ -87,4 +88,3 @@ def write(config): ) util.writeToFile(config.data_dir, config.pack_service, config.class_name + "Service.java", serviceint) - diff --git a/src/codefile/sql2outility.py b/src/codefile/sql2outility.py index 266806b..f2a6f3d 100644 --- a/src/codefile/sql2outility.py +++ b/src/codefile/sql2outility.py @@ -8,6 +8,7 @@ import org.sql2o.Connection; import org.sql2o.Query; + public class Sql2oUtility {{ {indent}public static T getInsertedId( {indent}{indent}String table, @@ -35,4 +36,3 @@ def write(config): ) util.writeToFile(config.data_dir, config.pack_utility, "Sql2oUtility.java", sql2outility) - diff --git a/src/utility/config.py b/src/utility/config.py index 3dbe472..544f3cf 100644 --- a/src/utility/config.py +++ b/src/utility/config.py @@ -211,7 +211,7 @@ def __init__(self, cmd_args, app_dir): col_type = col_types[id] varid = id.lower() - idsfirm += "{} {}, ".format(col_type, id.lower()) + idsfirm += "final {} {}, ".format(col_type, id.lower()) idslist += "{}, ".format(varid) idsfirm = idsfirm[:-2] @@ -388,4 +388,3 @@ def indent(self): @property def site(self): return self._site -