diff options
Diffstat (limited to 'openecomp-be/tools/zusammen-tools/src/main/java')
3 files changed, 13 insertions, 11 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java index b41f74fc69..3454b99dc2 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/exportinfo/ExportSerializer.java @@ -53,8 +53,8 @@ public class ExportSerializer { public void serializeResult(final ResultSet resultSet, final Set<String> filteredItems, final String filteredColumn, Set<String> vlms) { try { TableData tableData = new TableData(); - tableData.definitions = resultSet.getColumnDefinitions().asList().stream().map(ColumnDefinition::new).collect(Collectors.toList()); - String table = tableData.definitions.iterator().next().getTable(); + tableData.getDefinitions().addAll(resultSet.getColumnDefinitions().asList().stream().map(ColumnDefinition::new).collect(Collectors.toList())); + String table = tableData.getDefinitions().iterator().next().getTable(); boolean isElementTable = table.equals(ELEMENT_TABLE_NAME); Iterator<Row> iterator = resultSet.iterator(); iterator.forEachRemaining(row -> { @@ -62,14 +62,14 @@ public class ExportSerializer { return; } List<String> rowData = new ArrayList<>(); - for (int i = 0; i < tableData.definitions.size(); i++) { - ColumnDefinition columnDefinition = tableData.definitions.get(i); + for (int i = 0; i < tableData.getDefinitions().size(); i++) { + ColumnDefinition columnDefinition = tableData.getDefinitions().get(i); Name name = dataTypesMap.get(columnDefinition.getType()); boolean checkForVLM = isElementTable && columnDefinition.getName().equals(ELEMENT_INFO_COLUMN_NAME); Object data = convertByType(vlms, row, i, name, checkForVLM); rowData.add(data.toString()); } - tableData.rows.add(rowData); + tableData.getRows().add(rowData); }); ObjectMapper objectMapper = new ObjectMapper(); String fileName = ImportProperties.ROOT_DIRECTORY + File.separator + table + "_" + System.currentTimeMillis() + ".json"; diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java index 40486c8269..64c595caa5 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/importinfo/ImportSingleTable.java @@ -61,7 +61,7 @@ public class ImportSingleTable { TableData tableData = objectMapper.readValue(file.toFile(), TableData.class); Session session = CassandraSessionFactory.getSession(); PreparedStatement ps = getPrepareStatement(tableData, session); - tableData.rows.forEach(row -> executeQuery(session, ps, tableData.definitions, row)); + tableData.getRows().forEach(row -> executeQuery(session, ps, tableData.getDefinitions(), row)); } catch (IOException e) { Utils.logError(logger, e); } @@ -153,12 +153,12 @@ public class ImportSingleTable { } private String createQuery(TableData tableData) { - ColumnDefinition def = tableData.definitions.iterator().next(); + ColumnDefinition def = tableData.getDefinitions().iterator().next(); StringBuilder sb = new StringBuilder(1024); sb.append(INSERT_INTO).append(def.getKeyspace()).append(".").append(def.getTable()); - sb.append(tableData.definitions.stream().map(ColumnDefinition::getName) + sb.append(tableData.getDefinitions().stream().map(ColumnDefinition::getName) .collect(Collectors.joining(" , ", " ( ", " ) "))); - sb.append(VALUES).append(tableData.definitions.stream().map(definition -> "?") + sb.append(VALUES).append(tableData.getDefinitions().stream().map(definition -> "?") .collect(Collectors.joining(" , ", " ( ", " ) "))).append(";"); return sb.toString(); } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java index a6fdbd801e..77b6ca1b76 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/model/TableData.java @@ -21,8 +21,10 @@ package org.openecomp.core.tools.model; import java.util.ArrayList; import java.util.List; +import lombok.Getter; +@Getter public class TableData { - public List<ColumnDefinition> definitions = new ArrayList<>(); - public List<List<String>> rows = new ArrayList<>(); + private final List<ColumnDefinition> definitions = new ArrayList<>(); + private final List<List<String>> rows = new ArrayList<>(); } |