List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet getRow
@Override public XSSFRow getRow(int rownum)
From source file:es.SSII2.manager.ExcelManagerMail.java
public void actualizarDnis() throws IOException { int row;// w ww. jav a 2s . c o m int col = 15; FileInputStream file; file = new FileInputStream(new File(excel)); XSSFWorkbook workbook = new XSSFWorkbook(file); XSSFSheet sheet = workbook.getSheetAt(0); for (int i = 0; i < arrayWorkers.size(); i++) { row = i; XSSFRow rowEmail = sheet.getRow(row + 1); //coje la fila XSSFCell cellEmail = rowEmail.createCell(col); //crea la celda cellEmail.setCellValue(arrayWorkers.get(i).getEmail()); //escribe en el excel try (FileOutputStream outFile = new FileOutputStream(new File(excel))) { workbook.write(outFile); } } //for }
From source file:es.upm.oeg.tools.rdfshapes.patterns.DatatypeObjectPropertyPatterns.java
License:Apache License
public static void main(String[] args) throws Exception { String endpoint = "http://3cixty.eurecom.fr/sparql"; List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset()); String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset()); String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset()); String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset()); String objectCountQueryString = readFile(objectCountQueryPath, Charset.defaultCharset()); String tripleCountQueryString = readFile(tripleCountQueryPath, Charset.defaultCharset()); String literalCountQueryString = readFile(literalCountQueryPath, Charset.defaultCharset()); String blankCountQueryString = readFile(blankCountQueryPath, Charset.defaultCharset()); String iriCountQueryString = readFile(iriCountQueryPath, Charset.defaultCharset()); String datatypeCountQueryString = readFile(datatypeCountsPath, Charset.defaultCharset()); DecimalFormat df = new DecimalFormat("0.0000"); //Create the Excel workbook and sheet XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("Cardinality"); int currentExcelRow = 0; int classStartRow = 0; for (String clazz : classList) { System.out.println("Class: " + clazz); Map<String, String> litMap = new HashMap<>(); Map<String, String> iriMap = ImmutableMap.of("class", clazz); String queryString = bindQueryString(individualCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); int individualCount; List<RDFNode> c = executeQueryForList(queryString, endpoint, "c"); if (c.size() == 1) { individualCount = c.get(0).asLiteral().getInt(); } else {/*w w w.j av a 2 s . com*/ continue; } // If there are zero individuals, continue if (individualCount == 0) { throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match."); } classStartRow = currentExcelRow; XSSFRow row = sheet.createRow(currentExcelRow); XSSFCell cell = row.createCell(0); cell.setCellValue(clazz); litMap = new HashMap<>(); iriMap = ImmutableMap.of("class", clazz); queryString = bindQueryString(classPropertyQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p"); // System.out.println("***"); // System.out.println("### **" + clazz + "**"); // System.out.println("***"); // System.out.println(); cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER); for (RDFNode property : nodeList) { if (property.isURIResource()) { System.out.println(" " + property); int tripleCount; int objectCount; int literalCount; int blankCount; int iriCount; String propertyURI = property.asResource().getURI(); XSSFRow propertyRow = sheet.getRow(currentExcelRow); if (propertyRow == null) { propertyRow = sheet.createRow(currentExcelRow); } currentExcelRow++; XSSFCell propertyCell = propertyRow.createCell(1); propertyCell.setCellValue(propertyURI); litMap = new HashMap<>(); iriMap = ImmutableMap.of("class", clazz, "p", propertyURI); queryString = bindQueryString(tripleCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); c = executeQueryForList(queryString, endpoint, "c"); if (c.size() > 0) { tripleCount = c.get(0).asLiteral().getInt(); } else { tripleCount = 0; } queryString = bindQueryString(objectCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); c = executeQueryForList(queryString, endpoint, "c"); if (c.size() > 0) { objectCount = c.get(0).asLiteral().getInt(); } else { objectCount = 0; } queryString = bindQueryString(literalCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); c = executeQueryForList(queryString, endpoint, "c"); if (c.size() > 0) { literalCount = c.get(0).asLiteral().getInt(); } else { literalCount = 0; } queryString = bindQueryString(blankCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); c = executeQueryForList(queryString, endpoint, "c"); if (c.size() > 0) { blankCount = c.get(0).asLiteral().getInt(); } else { blankCount = 0; } queryString = bindQueryString(iriCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); c = executeQueryForList(queryString, endpoint, "c"); if (c.size() > 0) { iriCount = c.get(0).asLiteral().getInt(); } else { iriCount = 0; } XSSFCell objectCountCell = propertyRow.createCell(2); objectCountCell.setCellValue(objectCount); XSSFCell uniqueObjectsCell = propertyRow.createCell(3); uniqueObjectsCell.setCellValue(df.format(((double) objectCount) / tripleCount)); XSSFCell literalCell = propertyRow.createCell(4); literalCell.setCellValue(df.format((((double) literalCount) / objectCount))); XSSFCell iriCell = propertyRow.createCell(5); iriCell.setCellValue(df.format((((double) iriCount) / objectCount))); XSSFCell blankCell = propertyRow.createCell(6); blankCell.setCellValue(df.format((((double) blankCount) / objectCount))); if (literalCount > 0) { litMap = new HashMap<>(); iriMap = ImmutableMap.of("class", clazz, "p", propertyURI); queryString = bindQueryString(datatypeCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<Map<String, RDFNode>> solnMaps = executeQueryForList(queryString, endpoint, ImmutableSet.of("datatype", "c")); int i = 1; for (Map<String, RDFNode> soln : solnMaps) { String datatype = soln.get("datatype").asResource().getURI(); int count = soln.get("c").asLiteral().getInt(); XSSFCell dataCell = propertyRow.createCell(6 + i++); dataCell.setCellValue(datatype); dataCell = propertyRow.createCell(6 + i++); dataCell.setCellValue(df.format((((double) count) / objectCount))); } } // System.out.println("* " + propertyURI); // System.out.println(); // // System.out.println("| Object Count | Unique Objects | Literals | IRIs | Blank Nodes | "); // System.out.println("|---|---|---|---|---|"); // System.out.println(String.format("|%d|%d (%.2f%%) |%d (%.2f%%)|%d (%.2f%%)|%d (%.2f%%)|", // tripleCount, // objectCount, ((((double) objectCount)/tripleCount)*100), // literalCount, ((((double) literalCount)/objectCount)*100), // iriCount, ((((double) iriCount)/objectCount)*100), // blankCount, ((((double) blankCount)/objectCount)*100))); // System.out.println(); } } } String filename = "literals.xls"; FileOutputStream fileOut = new FileOutputStream(filename); wb.write(fileOut); fileOut.close(); }
From source file:es.upm.oeg.tools.rdfshapes.utils.CadinalityResultGenerator.java
License:Apache License
public static void main(String[] args) throws Exception { String endpoint = "http://3cixty.eurecom.fr/sparql"; List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset()); String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset()); String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset()); String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset()); DecimalFormat df = new DecimalFormat("0.0000"); //Create the Excel workbook and sheet XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("Cardinality"); int currentExcelRow = 0; int classStartRow = 0; for (String clazz : classList) { Map<String, String> litMap = new HashMap<>(); Map<String, String> iriMap = ImmutableMap.of("class", clazz); String queryString = bindQueryString(individualCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); int individualCount; List<RDFNode> c = executeQueryForList(queryString, endpoint, "c"); if (c.size() == 1) { individualCount = c.get(0).asLiteral().getInt(); } else {//from w w w . j ava 2 s . c o m continue; } // If there are zero individuals, continue if (individualCount == 0) { throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match."); } // System.out.println("***"); // System.out.println("### **" + clazz + "** (" + individualCount + ")"); // System.out.println("***"); // System.out.println(); classStartRow = currentExcelRow; XSSFRow row = sheet.createRow(currentExcelRow); XSSFCell cell = row.createCell(0); cell.setCellValue(clazz); cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER); queryString = bindQueryString(classPropertyQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p"); for (RDFNode property : nodeList) { if (property.isURIResource()) { DescriptiveStatistics stats = new DescriptiveStatistics(); String propertyURI = property.asResource().getURI(); // System.out.println("* " + propertyURI); // System.out.println(); XSSFRow propertyRow = sheet.getRow(currentExcelRow); if (propertyRow == null) { propertyRow = sheet.createRow(currentExcelRow); } currentExcelRow++; XSSFCell propertyCell = propertyRow.createCell(1); propertyCell.setCellValue(propertyURI); Map<String, String> litMap2 = new HashMap<>(); Map<String, String> iriMap2 = ImmutableMap.of("class", clazz, "p", propertyURI); queryString = bindQueryString(propertyCardinalityQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap2, LITERAL_BINDINGS, litMap2)); List<Map<String, RDFNode>> solnMaps = executeQueryForList(queryString, endpoint, ImmutableSet.of("card", "count")); int sum = 0; List<CardinalityCount> cardinalityList = new ArrayList<>(); if (solnMaps.size() > 0) { for (Map<String, RDFNode> soln : solnMaps) { int count = soln.get("count").asLiteral().getInt(); int card = soln.get("card").asLiteral().getInt(); for (int i = 0; i < count; i++) { stats.addValue(card); } CardinalityCount cardinalityCount = new CardinalityCount(card, count, (((double) count) / individualCount) * 100); cardinalityList.add(cardinalityCount); sum += count; } // Check for zero cardinality instances int count = individualCount - sum; if (count > 0) { for (int i = 0; i < count; i++) { stats.addValue(0); } CardinalityCount cardinalityCount = new CardinalityCount(0, count, (((double) count) / individualCount) * 100); cardinalityList.add(cardinalityCount); } } Map<Integer, Double> cardMap = new HashMap<>(); for (CardinalityCount count : cardinalityList) { cardMap.put(count.getCardinality(), count.getPrecentage()); } XSSFCell instanceCountCell = propertyRow.createCell(2); instanceCountCell.setCellValue(individualCount); XSSFCell minCell = propertyRow.createCell(3); minCell.setCellValue(stats.getMin()); XSSFCell maxCell = propertyRow.createCell(4); maxCell.setCellValue(stats.getMax()); XSSFCell p1 = propertyRow.createCell(5); p1.setCellValue(stats.getPercentile(1)); XSSFCell p99 = propertyRow.createCell(6); p99.setCellValue(stats.getPercentile(99)); XSSFCell mean = propertyRow.createCell(7); mean.setCellValue(df.format(stats.getMean())); for (int i = 0; i < 21; i++) { XSSFCell dataCell = propertyRow.createCell(8 + i); Double percentage = cardMap.get(i); if (percentage != null) { dataCell.setCellValue(df.format(percentage)); } else { dataCell.setCellValue(0); } } // System.out.println("| Min Card. |Max Card. |"); // System.out.println("|---|---|"); // System.out.println("| ? | ? |"); // System.out.println(); } } //System.out.println("class start: " + classStartRow + ", class end: " + (currentExcelRow -1)); //We have finished writting properties of one class, now it's time to merge the cells int classEndRow = currentExcelRow - 1; if (classStartRow < classEndRow) { sheet.addMergedRegion(new CellRangeAddress(classStartRow, classEndRow, 0, 0)); } } String filename = "3cixty.xls"; FileOutputStream fileOut = new FileOutputStream(filename); wb.write(fileOut); fileOut.close(); }
From source file:es.upm.oeg.tools.rdfshapes.utils.CardinalityTemplateGenerator.java
License:Apache License
public static void main(String[] args) throws Exception { OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF, ModelFactory.createDefaultModel()); model.read("http://dublincore.org/2012/06/14/dcelements.ttl"); String endpoint = "http://infra2.dia.fi.upm.es:8899/sparql"; List<String> classList = Files.readAllLines(Paths.get(classListPath), Charset.defaultCharset()); String classPropertyQueryString = readFile(classPropertyQueryPath, Charset.defaultCharset()); String propertyCardinalityQueryString = readFile(propertyCardinalityQueryPath, Charset.defaultCharset()); String individualCountQueryString = readFile(individualCountQueryPath, Charset.defaultCharset()); //Create the Excel workbook and sheet XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("Cardinality"); int currentExcelRow = 0; int classStartRow = 0; for (String clazz : classList) { Map<String, String> litMap = new HashMap<>(); Map<String, String> iriMap = ImmutableMap.of("class", clazz); String queryString = bindQueryString(individualCountQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); int individualCount; List<RDFNode> c = executeQueryForList(queryString, endpoint, "c"); if (c.size() == 1) { individualCount = c.get(0).asLiteral().getInt(); } else {/*from w ww .j ava 2 s . co m*/ continue; } // If there are zero individuals, continue if (individualCount == 0) { throw new IllegalStateException("Check whether " + classListPath + " and " + endpoint + " match."); } // System.out.println("***"); // System.out.println("### **" + clazz + "** (" + individualCount + ")"); // System.out.println("***"); // System.out.println(); classStartRow = currentExcelRow; XSSFRow row = sheet.createRow(currentExcelRow); XSSFCell cell = row.createCell(0); cell.setCellValue(clazz); cell.getCellStyle().setAlignment(CellStyle.ALIGN_CENTER); queryString = bindQueryString(classPropertyQueryString, ImmutableMap.of(IRI_BINDINGS, iriMap, LITERAL_BINDINGS, litMap)); List<RDFNode> nodeList = executeQueryForList(queryString, endpoint, "p"); for (RDFNode property : nodeList) { if (property.isURIResource()) { String propertyURI = property.asResource().getURI(); // System.out.println("* " + propertyURI); // System.out.println(); XSSFRow propertyRow = sheet.getRow(currentExcelRow); if (propertyRow == null) { propertyRow = sheet.createRow(currentExcelRow); } currentExcelRow++; XSSFCell propertyCell = propertyRow.createCell(1); propertyCell.setCellValue(propertyURI); // System.out.println("| Min Card. |Max Card. |"); // System.out.println("|---|---|"); // System.out.println("| ? | ? |"); // System.out.println(); } } //System.out.println("class start: " + classStartRow + ", class end: " + (currentExcelRow -1)); //We have finished writting properties of one class, now it's time to merge the cells int classEndRow = currentExcelRow - 1; if (classStartRow < classEndRow) { sheet.addMergedRegion(new CellRangeAddress(classStartRow, classEndRow, 0, 0)); } } String filename = "test.xls"; FileOutputStream fileOut = new FileOutputStream(filename); wb.write(fileOut); fileOut.close(); }
From source file:eu.alpinweiss.filegen.command.steps.impl.ReadInputParametersStepImpl.java
License:Apache License
@Override public void execute(Model model) { String parameter = model.getParameter(INPUT_PARAMETER); model.getFieldDefinitionList().clear(); try {//from w ww . j a v a2s .c o m FileInputStream file = new FileInputStream(new File(parameter)); try (XSSFWorkbook workbook = new XSSFWorkbook(file)) { XSSFSheet sheet = workbook.getSheetAt(0); int iterationCount = readIterationCount(sheet); String lineSeparator = readLineSeparator(sheet); String outputFileName = readOutputFileName(sheet); int sheetCount = readSheetCount(sheet); outputWriterHolder .writeValueInLine("Iterations: " + iterationCount + " lineSeparator: " + lineSeparator); List<Object[]> fields = new ArrayList<>(sheet.getLastRowNum() - 4); for (int i = 5; i <= sheet.getLastRowNum(); i++) { XSSFRow row = sheet.getRow(i); Object[] fieldDefinition = new Object[row.getLastCellNum()]; for (int y = 0; y < row.getLastCellNum(); y++) { XSSFCell cell = row.getCell(y); if (cell == null) { fieldDefinition[y] = null; break; } cell.setCellType(Cell.CELL_TYPE_STRING); fieldDefinition[y] = cell.toString(); } fields.add(fieldDefinition); } file.close(); for (Object[] field : fields) { FieldDefinition fieldDefinition = new FieldDefinition(); String name = getStringName(field[0]); if (name == null || "".equals(name)) { break; } fieldDefinition.setFieldName(name); String fieldType = (String) field[1]; fieldDefinition.setType( fieldType != null ? FieldType.valueOf(fieldType.toUpperCase()) : FieldType.STRING); String fieldNeedToGenerate = (String) field[2]; fieldDefinition.setGenerate( fieldNeedToGenerate != null ? Generate.valueOf(fieldNeedToGenerate.toUpperCase()) : Generate.N); if ((field.length > 3)) { if (field[3] != null && field[3] instanceof Number) { fieldDefinition.setPattern(field[3].toString()); } else { fieldDefinition.setPattern((String) field[3]); } } model.getFieldDefinitionList().add(fieldDefinition); } model.setRowCount(iterationCount); model.setLineSeparator(lineSeparator); model.setOutputFileName(outputFileName); model.setDataStorageCount(sheetCount); outputWriterHolder.writeValueInLine(""); workbook.close(); } } catch (FileNotFoundException e) { LOGGER.error("Can't read input parameters file", e); } catch (IOException e) { LOGGER.error("Error while reading xlsx file", e); } }
From source file:eu.alpinweiss.filegen.command.steps.impl.ReadInputParametersStepImpl.java
License:Apache License
private int readSheetCount(XSSFSheet sheet) { XSSFRow row = sheet.getRow(3); Cell cell = row.getCell(1);/*w w w . java 2s . c o m*/ return (int) cell.getNumericCellValue(); }
From source file:eu.alpinweiss.filegen.command.steps.impl.ReadInputParametersStepImpl.java
License:Apache License
private String readOutputFileName(XSSFSheet sheet) { XSSFRow row = sheet.getRow(2); Cell cell = row.getCell(1); return cell.getStringCellValue(); }
From source file:eu.alpinweiss.filegen.command.steps.impl.ReadInputParametersStepImpl.java
License:Apache License
private int readIterationCount(XSSFSheet sheet) { XSSFRow row = sheet.getRow(0); Cell cell = row.getCell(1);/* ww w. j a v a2 s.c om*/ return (int) cell.getNumericCellValue(); }
From source file:eu.alpinweiss.filegen.command.steps.impl.ReadInputParametersStepImpl.java
License:Apache License
private String readLineSeparator(XSSFSheet sheet) { XSSFRow row = sheet.getRow(1); Cell cell = row.getCell(1); return cell.getStringCellValue(); }
From source file:eu.riscoss.server.EntityManager.java
License:Apache License
private void readImportFile(RiscossDB db) throws Exception { //Load importing config xml file DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); FileInputStream f = new FileInputStream("resources/importation_config.xml"); Document doc = builder.parse(f); Element element = doc.getDocumentElement(); //Get relationships config info NodeList importNodes = element.getElementsByTagName("relationships"); Element e = (Element) importNodes.item(0); String sheet = e.getElementsByTagName("sheet_name").item(0).getTextContent(); List<Integer> entitiesColumns = new ArrayList<>(); NodeList ent = e.getElementsByTagName("layer"); while (ent != null) { Element el = (Element) ent.item(0); if (el != null) { entitiesColumns.add(Integer.valueOf(el.getAttribute("entity_column")) - 1); ent = el.getElementsByTagName("layer"); } else//from w ww . j a v a2 s . c o m break; } List<ConfigItem> config = new ArrayList<>(); //Get imported entitites config info NodeList cf = element.getElementsByTagName("entities"); Element impEnt = (Element) cf.item(0); NodeList configNodes = impEnt.getElementsByTagName("imported_entity"); for (int i = 0; i < configNodes.getLength(); ++i) { ConfigItem conf = new ConfigItem(); Element entity = (Element) configNodes.item(i); conf.sheet = entity.getElementsByTagName("sheet_name").item(0).getTextContent(); conf.nameColumn = Integer.parseInt(entity.getElementsByTagName("name_column").item(0).getTextContent()) - 1; List<Pair<String, Pair<Integer, Integer>>> definedIdItem = new ArrayList<>(); List<Pair<String, Integer>> definedValueItem = new ArrayList<>(); NodeList p = entity.getElementsByTagName("custom_information"); Element ee = (Element) p.item(0); NodeList prop = ee.getElementsByTagName("custom_field"); for (int j = 0; j < prop.getLength(); ++j) { Element b = (Element) prop.item(j); if (b.getElementsByTagName("id").item(0) != null) { String id = b.getElementsByTagName("id").item(0).getTextContent(); int column = Integer.parseInt(b.getElementsByTagName("value_column").item(0).getTextContent()) - 1; definedValueItem.add(new Pair<>(id, column)); } else { int column = Integer.parseInt(b.getElementsByTagName("id_column").item(0).getTextContent()) - 1; int val = Integer.parseInt(b.getElementsByTagName("value").item(0).getTextContent()); String prefix = b.getElementsByTagName("prefix").item(0).getTextContent(); definedIdItem.add(new Pair<>(prefix, new Pair<>(column, val))); } } conf.definedIdItem = definedIdItem; conf.definedValueItem = definedValueItem; config.add(conf); } File xlsx = new File("resources/entities_info.xlsx"); FileInputStream fis = new FileInputStream(xlsx); XSSFWorkbook wb = new XSSFWorkbook(fis); XSSFSheet ws = wb.getSheet(sheet); Map<String, Pair<String, String>> list = new HashMap<>(); Map<Integer, List<String>> entities = new HashMap<>(); List<Pair<String, String>> relationships = new ArrayList<>(); boolean read = true; int i = 6; while (read) { //For every valid row in xlsx file XSSFRow row = ws.getRow(i); if (row == null || row.getCell(0).toString().equals("")) read = false; else { //For every custom entity defined in i row for (int j = 0; j < config.size(); ++j) { String parent = row.getCell(config.get(j).nameColumn).toString(); if (!parent.equals("")) { int x = 0; while (x < entitiesColumns.size()) { if (entitiesColumns.get(x) == config.get(j).nameColumn) break; else ++x; } if (x > 0) relationships .add(new Pair<>(row.getCell(entitiesColumns.get(x - 1)).toString(), parent)); if (entities.containsKey(config.get(j).nameColumn)) entities.get(config.get(j).nameColumn).add(parent); else { List<String> n = new ArrayList<>(); n.add(parent); entities.put(config.get(j).nameColumn, n); } String prefix = ""; //For every custom info defined for j entity in i row for (int k = 0; k < config.get(j).definedIdItem.size(); ++k) { prefix = config.get(j).definedIdItem.get(k).getLeft(); if (!row.getCell(config.get(j).definedIdItem.get(k).getRight().getLeft()).toString() .equals("")) { checkNewInfo(parent, prefix + row .getCell(config.get(j).definedIdItem.get(k).getRight().getLeft()) .toString(), config.get(j).definedIdItem.get(k).getRight().getRight().toString(), list, db); } } for (int k = 0; k < config.get(j).definedValueItem.size(); ++k) { if (!row.getCell(config.get(j).definedValueItem.get(k).getRight()).toString() .equals("")) { String value = row.getCell(config.get(j).definedValueItem.get(k).getRight()) .toString(); checkNewInfo(parent, config.get(j).definedValueItem.get(k).getLeft(), value, list, db); } } } } ++i; } } Map<String, String> en = importEntities(entitiesColumns, entities, relationships, db); //Delete old imported data for entities Set<String> all = new HashSet<>(); for (List<String> s : entities.values()) all.addAll(s); for (String target : all) { for (String id : db.listRiskData(target)) { JsonObject o = (JsonObject) new JsonParser().parse(db.readRiskData(target, id)); if (o.get("type").toString().equals("\"imported\"")) { JsonObject delete = new JsonObject(); delete.addProperty("id", id); delete.addProperty("target", target); JsonArray array = new JsonArray(); array.add(delete); db.storeRiskData(delete.toString()); } } } for (String child : list.keySet()) { if (!list.get(child).getLeft().equals("") && !list.get(child).getRight().equals("")) storeRDR(child.split("@")[0], en.get(child.split("@")[0]), list.get(child).getLeft(), list.get(child).getRight(), db); } }