From 087480ff45811aa86f55d4821c4d5c7678957c41 Mon Sep 17 00:00:00 2001 From: Jyrki Oraskari <31693668+jyrkioraskari@users.noreply.github.com> Date: Thu, 4 Jan 2024 17:58:51 +0100 Subject: [PATCH] Code quality --- .../excelreport/IFCPropsTOExcelOnlineUI.java | 5 +- .../dc/excelreport/upload/WebFileHandler.java | 2 + .../dc/ifc2lbd/CreateOntology.java | 3 +- IFCtoLBD/src/main/java/examples/Example3.java | 13 +- IFCtoLBD/src/main/java/examples/Example4.java | 19 +- .../ifc2lbd/IFCtoLBDConverter.java | 60 ++- .../ifc2lbd/core/IFCtoLBDConverterCore.java | 118 +++--- .../ifc2lbd/core/IFCtoRDF.java | 6 +- .../ifc2lbd/core/Test1.java | 3 +- .../ifc2lbd/core/TestUTF8.java | 1 + .../ifc2lbd/core/utils/FileUtils.java | 2 +- .../ifc2lbd/core/utils/IfcOWLUtils.java | 22 +- .../ifc2lbd/core/utils/LBD_RDF_Utils.java | 79 ++-- .../ifc2lbd/core/utils/RDFUtils.java | 11 +- .../CreatePsetDescriptionOntologies.java | 7 +- .../ifc2lbd/core/valuesets/PropertySet.java | 13 +- .../ifc2lbd/geo/IFC_Geolocation.java | 8 +- .../ifc2lbd/geo/WktLiteral.java | 9 +- .../ifc2lbd/desktop/About.java | 2 +- .../ifc2lbd/desktop/ConversionThread.java | 1 + .../ifc2lbd/desktop/IFCtoLBDController.java | 31 +- .../ifc2lbd/desktop/About.java | 2 +- .../ifc2lbd/desktop/ConversionThread.java | 4 +- .../ifc2lbd/desktop/IFCtoLBDController.java | 367 +++++++++--------- .../ifc2lbd/desktop/ReadinInThread.java | 18 +- .../OperatingSystemCopyOf_IfcGeomServer.java | 1 - .../de/rwth_aachen/dc/lbd/IFCGeometry.java | 10 +- .../de/rwth_aachen/dc/lbd/ObjDescription.java | 8 +- .../de/rwth_aachen/dc/lbd/obj/IFCtoObj.java | 72 ++-- .../dc/lbd/obj/ObjGeometryTest.java | 23 +- .../org/ifcopenshell/IfcGeomServerClient.java | 9 +- .../IfcGeomServerClientEntity.java | 18 +- .../org/ifcopenshell/IfcOpenShellEngine.java | 54 +-- .../IfcOpenShellEnginePlugin.java | 25 +- .../IfcOpenShellEntityInstance.java | 1 + .../org/ifcopenshell/IfcOpenShellModel.java | 52 ++- .../dc/ifc2lbd/rest/IFCtoLBD_OpenAPI.java | 3 +- .../src/main/java/be/ugent/IfcSpfParser.java | 21 +- .../src/main/java/be/ugent/IfcSpfReader.java | 3 +- .../src/main/java/be/ugent/RDFWriter.java | 3 +- .../tech/ifcowl/ExpressReader.java | 162 ++++---- .../buildingsmart/tech/ifcowl/OWLWriter.java | 42 +- .../test/java/be/ugent/TestIfcSpfReader.java | 5 +- 43 files changed, 627 insertions(+), 691 deletions(-) diff --git a/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/IFCPropsTOExcelOnlineUI.java b/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/IFCPropsTOExcelOnlineUI.java index be25c2d2..369c74b6 100644 --- a/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/IFCPropsTOExcelOnlineUI.java +++ b/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/IFCPropsTOExcelOnlineUI.java @@ -262,8 +262,9 @@ private void extractIFCtoLBD(File ifcFile, RDFFormat rdfformat) { try { File tempExcelFile = File.createTempFile("ifc2lbd-", ".xlsx"); - FileOutputStream outputStream = new FileOutputStream(tempExcelFile); - workbook.write(outputStream); + try (FileOutputStream outputStream = new FileOutputStream(tempExcelFile)) { + workbook.write(outputStream); + } workbook.close(); Resource res = new FileResource(tempExcelFile); if (this.fileDownloader == null) { diff --git a/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/upload/WebFileHandler.java b/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/upload/WebFileHandler.java index f7c5181a..0e325780 100644 --- a/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/upload/WebFileHandler.java +++ b/IFCProps2ExcelOnline/src/main/java/de/rwth_aachen/dc/excelreport/upload/WebFileHandler.java @@ -30,6 +30,7 @@ public WebFileHandler(String userId, String uploads) { this.uploads = this.uploads + File.separator; } + @Override public OutputStream receiveUpload(String filename, String mimeType) { if ((filename == null) || filename.length() == 0) { Notification n = new Notification("A file has to be selected", " ", Notification.Type.ERROR_MESSAGE); @@ -62,6 +63,7 @@ public OutputStream receiveUpload(String filename, String mimeType) { return fos; } + @Override public void uploadSucceeded(SucceededEvent event) { File file = new File(this.uploads + event.getFilename()); if (!file.exists()) { diff --git a/IFCtoLBD/src/main/java/de/rwth_aachen/dc/ifc2lbd/CreateOntology.java b/IFCtoLBD/src/main/java/de/rwth_aachen/dc/ifc2lbd/CreateOntology.java index f722577a..57d394a7 100644 --- a/IFCtoLBD/src/main/java/de/rwth_aachen/dc/ifc2lbd/CreateOntology.java +++ b/IFCtoLBD/src/main/java/de/rwth_aachen/dc/ifc2lbd/CreateOntology.java @@ -83,7 +83,8 @@ public CreateOntology() { } - public static void main(String[] args) { + @SuppressWarnings("unused") + public static void main(String[] args) { new CreateOntology(); } } diff --git a/IFCtoLBD/src/main/java/examples/Example3.java b/IFCtoLBD/src/main/java/examples/Example3.java index 6e6748bc..3193bc05 100644 --- a/IFCtoLBD/src/main/java/examples/Example3.java +++ b/IFCtoLBD/src/main/java/examples/Example3.java @@ -26,12 +26,13 @@ public static void main(String[] args) { + "SELECT ?e WHERE {\r\n" + " ?e a bot:Element .\r\n" + "} "); - QueryExecution queryExecution = QueryExecutionFactory.create(query, m); - ResultSet rs = queryExecution.execSelect(); - rs.forEachRemaining(qs -> { - System.out.println("BOT element: "+qs.get("e").asResource().getLocalName()); - - }); + try (QueryExecution queryExecution = QueryExecutionFactory.create(query, m)) { + ResultSet rs = queryExecution.execSelect(); + rs.forEachRemaining(qs -> { + System.out.println("BOT element: "+qs.get("e").asResource().getLocalName()); + + }); + } } catch (Exception e) { e.printStackTrace(); } diff --git a/IFCtoLBD/src/main/java/examples/Example4.java b/IFCtoLBD/src/main/java/examples/Example4.java index 5bff3360..9e00173a 100644 --- a/IFCtoLBD/src/main/java/examples/Example4.java +++ b/IFCtoLBD/src/main/java/examples/Example4.java @@ -46,15 +46,16 @@ public static void main(String[] args) { + " ?g ?wkt .\r\n" + " ?g fog:asObj_v3.0-obj ?obj \r\n" + "} "); - QueryExecution queryExecution = QueryExecutionFactory.create(query, m); - ResultSet rs = queryExecution.execSelect(); - rs.forEachRemaining(qs -> { - System.out.println("BOT element: "+qs.get("e").asResource().getLocalName()); - System.out.println("BOT element WKT: "+qs.get("wkt")); - System.out.println("BOT element OBJ: "+qs.get("obj")); - - }); - //m.write(System.out, "TTL"); + try (QueryExecution queryExecution = QueryExecutionFactory.create(query, m)) { + ResultSet rs = queryExecution.execSelect(); + rs.forEachRemaining(qs -> { + System.out.println("BOT element: "+qs.get("e").asResource().getLocalName()); + System.out.println("BOT element WKT: "+qs.get("wkt")); + System.out.println("BOT element OBJ: "+qs.get("obj")); + + }); + //m.write(System.out, "TTL"); + } } } catch (Exception e) { e.printStackTrace(); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/IFCtoLBDConverter.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/IFCtoLBDConverter.java index a16bf9c8..408b7cb6 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/IFCtoLBDConverter.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/IFCtoLBDConverter.java @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.IOException; import java.util.List; import java.util.Optional; import java.util.Timer; @@ -249,52 +248,41 @@ public Model convert(String ifc_filename) { return this.lbd_general_output_model; } - private String unzip(String ifcZipFile) { - ZipInputStream zis = null; - try { + private static String unzip(String ifcZipFile) { + try (ZipInputStream zis = new ZipInputStream(new FileInputStream(ifcZipFile));){ byte[] buffer = new byte[1024]; - zis = new ZipInputStream(new FileInputStream(ifcZipFile)); + ZipEntry zipEntry = zis.getNextEntry(); while (zipEntry != null) { System.out.println("entry: " + zipEntry); //String name = zipEntry.getName().split("\\.")[0]; File newFile = File.createTempFile("ifc", ".ifc"); - // write file content - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); + // JO 2024 + try (// write file content + FileOutputStream fos = new FileOutputStream(newFile)) { + int len; + while ((len = zis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + fos.close(); } - fos.close(); - zipEntry = zis.getNextEntry(); zis.close(); newFile.deleteOnExit(); return newFile.getAbsolutePath(); } - } catch (FileNotFoundException e) { - try { - if(zis!=null) - zis.close(); - } catch (IOException e1) { - e1.printStackTrace(); - } + } catch (FileNotFoundException e) { e.printStackTrace(); } catch (Exception e) { - try { - if(zis!=null) - zis.close(); - } catch (IOException e1) { - e1.printStackTrace(); - } + e.printStackTrace(); } return null; } - public CompletableFuture getgeom(String ifc_filename) throws InterruptedException { + public CompletableFuture getgeom(String ifc_filename) { CompletableFuture completableFuture = new CompletableFuture<>(); Executors.newCachedThreadPool().submit(() -> { @@ -417,11 +405,7 @@ public boolean convert_read_in_phase(String ifc_filename, String target_file, bo CompletableFuture future_ifc_geometry = null; if (hasGeometry) - try { - future_ifc_geometry = getgeom(ifc_filename); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } + future_ifc_geometry = getgeom(ifc_filename); this.ifcowl_model = readAndConvertIFC2ifcOWL(ifc_filename, uriBase.get(), !exportIfcOWL, target_file, hasPerformanceBoost); // Before: @@ -495,6 +479,7 @@ public Model convert_LBD_phase(boolean hasBuildingElements, } + @SuppressWarnings("unused") public static void main(String[] args) { JenaSystem.init(); if (args.length > 3) { @@ -519,19 +504,20 @@ public static void main(String[] args) { } else if (args.length == 1) { // directory upload final List inputFiles; - final List outputFiles; + //final List outputFiles; //TODO Check this inputFiles = FileUtils.listFiles(args[0]); - outputFiles = null; + //outputFiles = null; for (int i = 0; i < inputFiles.size(); ++i) { final String inputFile = inputFiles.get(i); String outputFile; if (inputFile.endsWith(".ifc")) { - if (outputFiles == null) { + //TODO Check this + //if (outputFiles == null) { outputFile = inputFile.substring(0, inputFile.length() - 4) + ".ttl"; - } else { - outputFile = outputFiles.get(i); - } + //} else { + // outputFile = outputFiles.get(i); + //} outputFile = outputFile.replaceAll(args[0], args[0] + "\\___out\\"); String copyFile = inputFile.replaceAll(args[0], args[0] + "\\___done\\"); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoLBDConverterCore.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoLBDConverterCore.java index ef33319c..4da3c708 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoLBDConverterCore.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoLBDConverterCore.java @@ -2,7 +2,6 @@ package org.linkedbuildingdata.ifc2lbd.core; import java.io.File; -import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; @@ -784,43 +783,42 @@ private Resource addSingleElement(Resource ifcOWL_element) { }); this.included_elements.add(ifcOWL_element); return lbd_element; - } else { //TODO Statement unnecessarily nested within else clause. The corresponding then clause does not complete normally - if (ifcowl_type.isPresent()) { - Resource lbd_element = LBD_RDF_Utils.createformattedURIRecource(ifcOWL_element, - this.lbd_general_output_model, "ifcOWL_" + ifcowl_type.get().getLocalName(), this.ifcOWL, - this.uriBase.get(), this.exportIfcOWL_setting); - String guid = IfcOWLUtils.getGUID(ifcOWL_element, this.ifcOWL); - String uncompressed_guid = GuidCompressor.uncompressGuidString(guid); - addGeometry(lbd_element, guid); - Resource lbd_property_object = this.lbd_product_output_model.createResource(lbd_element.getURI()); - if (predefined_type.isPresent()) { - Resource product = this.lbd_product_output_model - .createResource(ifcowl_type.get().getURI() + "-" + predefined_type.get()); - lbd_property_object.addProperty(RDF.type, product); - } - lbd_property_object.addProperty(RDF.type, ifcowl_type.get()); - lbd_element.addProperty(RDF.type, BOT.element); + } + if (ifcowl_type.isPresent()) { + Resource lbd_element = LBD_RDF_Utils.createformattedURIRecource(ifcOWL_element, + this.lbd_general_output_model, "ifcOWL_" + ifcowl_type.get().getLocalName(), this.ifcOWL, + this.uriBase.get(), this.exportIfcOWL_setting); + String guid = IfcOWLUtils.getGUID(ifcOWL_element, this.ifcOWL); + String uncompressed_guid = GuidCompressor.uncompressGuidString(guid); + addGeometry(lbd_element, guid); + Resource lbd_property_object = this.lbd_product_output_model.createResource(lbd_element.getURI()); + if (predefined_type.isPresent()) { + Resource product = this.lbd_product_output_model + .createResource(ifcowl_type.get().getURI() + "-" + predefined_type.get()); + lbd_property_object.addProperty(RDF.type, product); + } + lbd_property_object.addProperty(RDF.type, ifcowl_type.get()); + lbd_element.addProperty(RDF.type, BOT.element); - IfcOWLUtils.listPropertysets(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) - .forEach(propertyset -> { - PropertySet p_set = this.propertysets.get(propertyset.getURI()); - if (p_set != null) - p_set.connect(lbd_element, uncompressed_guid); - }); - addAttrributes(this.lbd_property_output_model, ifcOWL_element, lbd_element); + IfcOWLUtils.listPropertysets(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) + .forEach(propertyset -> { + PropertySet p_set = this.propertysets.get(propertyset.getURI()); + if (p_set != null) + p_set.connect(lbd_element, uncompressed_guid); + }); + addAttrributes(this.lbd_property_output_model, ifcOWL_element, lbd_element); - IfcOWLUtils.listHosted_Elements(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) - .forEach(ifc_element2 -> { - connectElement(lbd_element, BOT.hasSubElement, ifc_element2); - }); + IfcOWLUtils.listHosted_Elements(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) + .forEach(ifc_element2 -> { + connectElement(lbd_element, BOT.hasSubElement, ifc_element2); + }); - IfcOWLUtils.listAggregated_Elements(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) - .forEach(ifc_element2 -> { - connectElement(lbd_element, BOT.hasSubElement, ifc_element2); - }); - this.included_elements.add(ifcOWL_element); - return lbd_element; - } + IfcOWLUtils.listAggregated_Elements(ifcOWL_element, this.ifcOWL).stream().map(rn -> rn.asResource()) + .forEach(ifc_element2 -> { + connectElement(lbd_element, BOT.hasSubElement, ifc_element2); + }); + this.included_elements.add(ifcOWL_element); + return lbd_element; } return null; } @@ -1085,36 +1083,32 @@ protected Model readAndConvertIFC2ifcOWL(String ifc_file, String uriBase, boolea } } - try { - Model m = ModelFactory.createDefaultModel(); - this.eventBus.post(new IFCtoLBD_SystemStatusEvent("IFCtoRDF conversion")); + Model m = ModelFactory.createDefaultModel(); + this.eventBus.post(new IFCtoLBD_SystemStatusEvent("IFCtoRDF conversion")); - if (hasPerformanceBoost) { - File pruned_file_ = IfcOWLUtils.filterIFC(new File(ifc_file)); - this.ontURI = rj.convert_into_rdf(pruned_file_.getAbsolutePath(), outputFile.getAbsolutePath(), - uriBase, hasPerformanceBoost); - } else { - this.ontURI = rj.convert_into_rdf(ifc_file, outputFile.getAbsolutePath(), uriBase, - hasPerformanceBoost); - } + if (hasPerformanceBoost) { + File pruned_file_ = IfcOWLUtils.filterIFC(new File(ifc_file)); + this.ontURI = rj.convert_into_rdf(pruned_file_.getAbsolutePath(), outputFile.getAbsolutePath(), + uriBase, hasPerformanceBoost); + } else { + this.ontURI = rj.convert_into_rdf(ifc_file, outputFile.getAbsolutePath(), uriBase, + hasPerformanceBoost); + } - this.eventBus.post(new IFCtoLBD_SystemStatusEvent("ifcOWL ready: reading in the model.")); + this.eventBus.post(new IFCtoLBD_SystemStatusEvent("ifcOWL ready: reading in the model.")); - // File t2 = IfcOWLUtils.filterContent(outputFile); // Performance!! - // if (t2 != null) { - // RDFDataMgr.read(m, t2.getAbsolutePath()); - // } else - // RDFDataMgr.read(m, outputFile.getAbsolutePath()); - File t2 = IfcOWLUtils.characterCoding(outputFile); // UTF-8 characters - if (t2 != null) { - RDFDataMgr.read(m, t2.getAbsolutePath()); - } else - RDFDataMgr.read(m, outputFile.getAbsolutePath()); - System.out.println("ifcOWL read in done"); - return m; - } catch (IOException e) { - e.printStackTrace(); - } + // File t2 = IfcOWLUtils.filterContent(outputFile); // Performance!! + // if (t2 != null) { + // RDFDataMgr.read(m, t2.getAbsolutePath()); + // } else + // RDFDataMgr.read(m, outputFile.getAbsolutePath()); + File t2 = IfcOWLUtils.characterCoding(outputFile); // UTF-8 characters + if (t2 != null) { + RDFDataMgr.read(m, t2.getAbsolutePath()); + } else + RDFDataMgr.read(m, outputFile.getAbsolutePath()); + System.out.println("ifcOWL read in done"); + return m; } catch (Exception e) { this.eventBus.post(new IFCtoLBD_SystemErrorEvent(this.getClass().getSimpleName(), diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoRDF.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoRDF.java index 1a4dbc15..82a8883a 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoRDF.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/IFCtoRDF.java @@ -24,8 +24,8 @@ public class IFCtoRDF extends IfcSpfReader { - public Optional convert_into_rdf(String ifcFile, String outputFile, String baseURI,boolean hasPerformanceBoost) throws IOException { - i = 0; + public Optional convert_into_rdf(String ifcFile, String outputFile, String baseURI,boolean hasPerformanceBoost) { + this.i = 0; PrintStream orgSystemOut = System.out; PrintStream orgSystemError = System.err; @@ -36,7 +36,7 @@ public Optional convert_into_rdf(String ifcFile, String outputFile, Stri timer.schedule(new TimerTask() { @Override public void run() { - eventBus.post(new IFCtoLBD_SystemStatusEvent("IFCtoRDF running " + i++)); + IFCtoRDF.this.eventBus.post(new IFCtoLBD_SystemStatusEvent("IFCtoRDF running " + IFCtoRDF.this.i++)); } }, 1000, 1000); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/Test1.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/Test1.java index be40f4b8..823b8f21 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/Test1.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/Test1.java @@ -7,7 +7,8 @@ public class Test1 { - public static void main(String[] args) { try { + @SuppressWarnings("unused") + public static void main(String[] args) { try { File ifc_file = new File("C:\\test\\bim4ren\\BIM4Ren_DUNANT_cleaned_IFC2x3.ifc"); File temp_file = File.createTempFile("ifc2lbd", "test.ttl"); new IFCtoLBDConverter(ifc_file.getAbsolutePath(), "https://dot.dc.rwth-aachen.de/IFCtoLBDset#", temp_file.getAbsolutePath(), 3, true, false, true, false, false, true); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/TestUTF8.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/TestUTF8.java index 8d93a5ec..63c475e4 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/TestUTF8.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/TestUTF8.java @@ -13,6 +13,7 @@ static private String unIFCUnicode(String txt) { switch(state) { + default: case 0: if(ch=='\\' || ch=='/') state=1; diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/FileUtils.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/FileUtils.java index 1e4de090..a852ae42 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/FileUtils.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/FileUtils.java @@ -78,7 +78,7 @@ public static List getListofFiles(String dir, String extension) { * @return List of files found */ public static List listFiles(String dir) { - List goodFiles = new ArrayList(); + List goodFiles = new ArrayList<>(); File folder = new File(dir); File[] listOfFiles = folder.listFiles(); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/IfcOWLUtils.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/IfcOWLUtils.java index 55a0075c..0c942d45 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/IfcOWLUtils.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/IfcOWLUtils.java @@ -81,11 +81,10 @@ private static RDFStep[] getNextLevelPath(IfcOWL ifcOWL) { RDFStep[] path = { new InvRDFStep(ifcOWL.getRelatingObject_IfcRelDecomposes()), new RDFStep(ifcOWL.getRelatedObjects_IfcRelDecomposes()) }; return path; - } else { - RDFStep[] path = { new InvRDFStep(ifcOWL.getProperty("relatingObject_IfcRelAggregates")), - new RDFStep(ifcOWL.getProperty("relatedObjects_IfcRelAggregates")) }; - return path; } + RDFStep[] path = { new InvRDFStep(ifcOWL.getProperty("relatingObject_IfcRelAggregates")), + new RDFStep(ifcOWL.getProperty("relatedObjects_IfcRelAggregates")) }; + return path; } @@ -94,8 +93,7 @@ public static Resource getIfcProject(IfcOWL ifcOWL, Model ifcowl_model) { List list= RDFUtils.pathQuery(ifcowl_model.getResource(ifcOWL.getIfcProject()), path); if(!list.isEmpty()) return list.get(0).asResource(); - else - return null; + return null; } @@ -299,11 +297,10 @@ private static RDFStep[] getPropertySetPath(IfcOWL ifcOWL) { RDFStep[] path = { new InvRDFStep(ifcOWL.getRelatedObjects_IfcRelDefines()), new RDFStep(ifcOWL.getRelatingPropertyDefinition_IfcRelDefinesByProperties()) }; return path; - } else { - RDFStep[] path = { new InvRDFStep(ifcOWL.getProperty("relatedObjects_IfcRelDefinesByProperties")), - new RDFStep(ifcOWL.getProperty("relatingPropertyDefinition_IfcRelDefinesByProperties")) }; - return path; } + RDFStep[] path = { new InvRDFStep(ifcOWL.getProperty("relatedObjects_IfcRelDefinesByProperties")), + new RDFStep(ifcOWL.getProperty("relatingPropertyDefinition_IfcRelDefinesByProperties")) }; + return path; } private static RDFStep[] getIfcTypeObjectPropertySetPath(IfcOWL ifcOWL) { @@ -441,8 +438,7 @@ public static String getExpressSchema(String ifcFile) { return "IFC4x1"; if (strLine.indexOf("IFC4") != -1) // Should do also IFC4X2 return "IFC4_ADD2"; //JO 2020 to enable IFCPOLYGONALFACESET that was found in an IFC4 model - else - return null; + return null; } } } @@ -885,6 +881,7 @@ static private String unIFCUnicode(String txt) { switch(state) { + default: case 0: if(ch=='\\' ) state=1; @@ -947,6 +944,7 @@ private static List split(String s) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (state) { + default: case 2: if(!esc) if (c == '\"' || c == '\'') diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/LBD_RDF_Utils.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/LBD_RDF_Utils.java index 6af554f5..95f390d2 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/LBD_RDF_Utils.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/LBD_RDF_Utils.java @@ -43,13 +43,12 @@ public static Resource createformattedURIRecource(Resource r, Model m, String pr if (exportIfcOWL) uri.addProperty(OWL.sameAs, r); return uri; - } else { - Resource guid_uri = m.createResource( - uriBase + product_type.toLowerCase() + "_" + GuidCompressor.uncompressGuidString(guid)); - if (exportIfcOWL) - guid_uri.addProperty(OWL.sameAs, r); - return guid_uri; } + Resource guid_uri = m.createResource( + uriBase + product_type.toLowerCase() + "_" + GuidCompressor.uncompressGuidString(guid)); + if (exportIfcOWL) + guid_uri.addProperty(OWL.sameAs, r); + return guid_uri; } @@ -68,32 +67,28 @@ public static Resource createformattedHierarchicalURIRecource(Resource r, Model System.out.println("name nul & guid "); return guid_uri; } - else - { - String localName = r.getLocalName(); - if (localName.startsWith("IfcPropertySingleValue")) { - if (localName.lastIndexOf('_') > 0) - localName = localName.substring(localName.lastIndexOf('_') + 1); - Resource uri = m.createResource(uriBase + "propertySingleValue_" + localName); - if (exportIfcOWL) - uri.addProperty(OWL.sameAs, r); - return uri; - } - if (localName.toLowerCase().startsWith("ifc")) - localName = localName.substring(3); - Resource uri = m.createResource(uriBase + localName); + String localName = r.getLocalName(); + if (localName.startsWith("IfcPropertySingleValue")) { + if (localName.lastIndexOf('_') > 0) + localName = localName.substring(localName.lastIndexOf('_') + 1); + Resource uri = m.createResource(uriBase + "propertySingleValue_" + localName); if (exportIfcOWL) uri.addProperty(OWL.sameAs, r); - System.out.println("name & guid nul"); return uri; } - } else { - Resource guid_uri = m.createResource(uriBase + element_url_name); + if (localName.toLowerCase().startsWith("ifc")) + localName = localName.substring(3); + Resource uri = m.createResource(uriBase + localName); if (exportIfcOWL) - guid_uri.addProperty(OWL.sameAs, r); - System.out.println("name: "+element_url_name); - return guid_uri; + uri.addProperty(OWL.sameAs, r); + System.out.println("name & guid nul"); + return uri; } + Resource guid_uri = m.createResource(uriBase + element_url_name); + if (exportIfcOWL) + guid_uri.addProperty(OWL.sameAs, r); + System.out.println("name: "+element_url_name); + return guid_uri; } public static Resource createformattedHierarchicalURIRecource(Resource r, Model m, String product_type, IfcOWL ifcOWL_ns, Resource upper_url, boolean exportIfcOWL) { @@ -109,30 +104,26 @@ public static Resource createformattedHierarchicalURIRecource(Resource r, Model guid_uri.addProperty(OWL.sameAs, r); return guid_uri; } - else - { - String localName = r.getLocalName(); - if (localName.startsWith("IfcPropertySingleValue")) { - if (localName.lastIndexOf('_') > 0) - localName = localName.substring(localName.lastIndexOf('_') + 1); - Resource uri = m.createResource(upper_url.toString() + "/" + "propertySingleValue_" + localName); - if (exportIfcOWL) - uri.addProperty(OWL.sameAs, r); - return uri; - } - if (localName.toLowerCase().startsWith("ifc")) - localName = localName.substring(3); - Resource uri = m.createResource(upper_url.toString() + "/" + localName); + String localName = r.getLocalName(); + if (localName.startsWith("IfcPropertySingleValue")) { + if (localName.lastIndexOf('_') > 0) + localName = localName.substring(localName.lastIndexOf('_') + 1); + Resource uri = m.createResource(upper_url.toString() + "/" + "propertySingleValue_" + localName); if (exportIfcOWL) uri.addProperty(OWL.sameAs, r); return uri; } - } else { - Resource guid_uri = m.createResource(upper_url.toString() + "/" + element_url_name); + if (localName.toLowerCase().startsWith("ifc")) + localName = localName.substring(3); + Resource uri = m.createResource(upper_url.toString() + "/" + localName); if (exportIfcOWL) - guid_uri.addProperty(OWL.sameAs, r); - return guid_uri; + uri.addProperty(OWL.sameAs, r); + return uri; } + Resource guid_uri = m.createResource(upper_url.toString() + "/" + element_url_name); + if (exportIfcOWL) + guid_uri.addProperty(OWL.sameAs, r); + return guid_uri; } diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/RDFUtils.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/RDFUtils.java index d98e205a..0b95f6b4 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/RDFUtils.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/RDFUtils.java @@ -130,7 +130,6 @@ public static void writeDataset(Dataset ds, String target_file, EventBus eventBu */ public static void readInOntologyTTL(Model model, String ontology_file, EventBus eventBus) { - @SuppressWarnings("resource") InputStream in = null; try { in = IFCtoLBDConverter.class.getResourceAsStream("/" + ontology_file); @@ -211,21 +210,21 @@ public static void copyTriples(int level, RDFNode r, Model output_model) { public static List pathQuery(Resource r, RDFStep[] path) { List path_list = Arrays.asList(path); if (r.getModel() == null) - return new ArrayList(); + return new ArrayList<>(); Optional step = path_list.stream().findFirst(); if (step.isPresent()) { List step_result = step.get().next(r); if (path.length > 1) { - final List result = new ArrayList(); + final List result = new ArrayList<>(); step_result.stream().filter(rn1 -> rn1.isResource()).map(rn2 -> rn2.asResource()).forEach(r1 -> { List tail = path_list.stream().skip(1).collect(Collectors.toList()); result.addAll(pathQuery(r1, tail.toArray(new RDFStep[tail.size()]))); }); return result; - } else - return step_result; + } + return step_result; } - return new ArrayList(); + return new ArrayList<>(); } /** diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/ontology/CreatePsetDescriptionOntologies.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/ontology/CreatePsetDescriptionOntologies.java index b744eef9..0d6603b9 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/ontology/CreatePsetDescriptionOntologies.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/utils/ontology/CreatePsetDescriptionOntologies.java @@ -24,9 +24,8 @@ public class CreatePsetDescriptionOntologies { public static void readInOntologyTTL(Model model, String ontology_file) { - try { - InputStream in; - in = new FileInputStream(new File(ontology_file)); + // JO 2024 + try (InputStream in = new FileInputStream(new File(ontology_file))) { model.read(in, null, "TTL"); in.close(); } catch (FileNotFoundException e) { @@ -95,7 +94,7 @@ public static void run(String config,String ontfile,String ontology) { System.out.println("java -jar C:\\temp\\IFC-PSD\\widoco-1.4.14-jar-with-dependencies.jar -confFile "+config+" -ontFile "+ontfile+" -rewriteAll -excludeIntroduction -includeAnnotationProperties -uniteSections -outFolder C:\\temp\\IFC-PSD\\out\\"+ontology); } - public static void generate(String[] args) { + public static void generate(@SuppressWarnings("unused") String[] args) { List files = FileUtils.listFiles("C:\\temp\\IFC-PSD\\psets"); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/valuesets/PropertySet.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/valuesets/PropertySet.java index fd7f5e6e..c95d069d 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/valuesets/PropertySet.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/core/valuesets/PropertySet.java @@ -286,14 +286,11 @@ public Optional isExternal() { if (val == null) return Optional.empty(); - else { - if (!val.isLiteral()) - return Optional.empty(); - if (val.asLiteral().getValue().equals(true)) - return Optional.of(true); - else - return Optional.of(false); - } + if (!val.isLiteral()) + return Optional.empty(); + if (val.asLiteral().getValue().equals(true)) + return Optional.of(true); + return Optional.of(false); } diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/IFC_Geolocation.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/IFC_Geolocation.java index 49bf6561..86277b7a 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/IFC_Geolocation.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/IFC_Geolocation.java @@ -39,8 +39,8 @@ public class IFC_Geolocation { private static Property ifcSiteProperty; - private static List latitude = new ArrayList(); - private static List longitude = new ArrayList(); + private static List latitude = new ArrayList<>(); + private static List longitude = new ArrayList<>(); private final String ns1; private final String ns3; @@ -71,7 +71,7 @@ public String addGeolocation(Model model) //Author Kris McGlinn - This function takes the Model and a resources, and adds it to that resourse in the model //For wkt literal, a seperate class WktLiteral java is required, to add the literal datatype to the Model - private String addWKTGeometryToModel() + private static String addWKTGeometryToModel() { latitude = longLatNegativeConvert(latitude); @@ -88,7 +88,7 @@ private String addWKTGeometryToModel() //Author Kris McGlinn - This method changes the sign of the longitude or latitude values in a List - private List longLatNegativeConvert(List l) + private static List longLatNegativeConvert(List l) { String s = (String)l.get(l.size()-1); int x = Integer.parseInt(s); diff --git a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/WktLiteral.java b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/WktLiteral.java index 2a903e87..b761660f 100644 --- a/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/WktLiteral.java +++ b/IFCtoLBD/src/main/java/org/linkedbuildingdata/ifc2lbd/geo/WktLiteral.java @@ -20,14 +20,16 @@ private WktLiteral() { * Convert a value of this datatype out * to lexical form. */ - public String unparse(Object value) { + @Override + public String unparse(Object value) { return value.toString(); } /** * Parse a lexical form of this datatype to a value */ - public Object parse(String lexicalForm) { + @Override + public Object parse(String lexicalForm) { return new TypedValue(String.format("%s %s", WktLiteral.CRS84, lexicalForm), this.getURI()); } @@ -40,7 +42,8 @@ public Object parse(String lexicalForm) { * @param value2 Second value to compare * @return Value to determine whether both are equal. */ - public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { + @Override + public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue()); } diff --git a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java index ec9772f8..f360fbaa 100644 --- a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java +++ b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java @@ -62,7 +62,7 @@ public About(Stage owner) root.setEffect(r); Scene scene = new Scene(root, 550.0, 250.0, Color.BLACK); EventHandler ehme; - ehme = new EventHandler() + ehme = new EventHandler<>() { public void handle(MouseEvent event) { diff --git a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java index 8a3c54e5..e5ca5918 100644 --- a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java +++ b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java @@ -76,6 +76,7 @@ public ConversionThread(String ifc_filename, String uriBase, String target_file, this.hasBoundingBoxWKT=hasBoundingBoxWKT; } + @Override public Integer call() throws Exception { try { try { diff --git a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java index 105ec1c4..e52298ff 100644 --- a/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java +++ b/IFCtoLBD_Desktop/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java @@ -254,15 +254,15 @@ private void selectIFCFile() { Stage stage = (Stage) myMenuBar.getScene().getWindow(); File file = null; - if (fc_ifc == null) { - fc_ifc = new FileChooser(); - String work_directory = prefs.get("ifc_work_directory", "."); + if (this.fc_ifc == null) { + this.fc_ifc = new FileChooser(); + String work_directory = this.prefs.get("ifc_work_directory", "."); System.out.println("workdir got:" + work_directory); File fwd = new File(work_directory); - if (fwd != null && fwd.exists()) - fc_ifc.setInitialDirectory(fwd.getParentFile()); + if (fwd.exists()) + this.fc_ifc.setInitialDirectory(fwd.getParentFile()); else - fc_ifc.setInitialDirectory(new File(".")); + this.fc_ifc.setInitialDirectory(new File(".")); } FileChooser.ExtensionFilter ef1; ef1 = new FileChooser.ExtensionFilter("IFC documents (*.ifc)", "*.ifc"); @@ -414,14 +414,16 @@ private void convertIFCToRDF() { } - @Override + @SuppressWarnings("unused") + @Override public void initialize(URL location, ResourceBundle resources) { this.eventBus.register(this); this.border.widthProperty().bind(this.root.widthProperty()); this.border.heightProperty().bind(this.root.heightProperty()); // Accepts dropping new EventHandler() { - public void handle(DragEvent event) { + @Override + public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (db.hasFiles()) { event.acceptTransferModes(TransferMode.COPY); @@ -433,7 +435,7 @@ public void handle(DragEvent event) { }; // Accepts dropping - EventHandler ad_conversion = new EventHandler() { + EventHandler ad_conversion = new EventHandler<>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (db.hasFiles()) { @@ -445,7 +447,7 @@ public void handle(DragEvent event) { }; // Dropping over surface - EventHandler dh_conversion = new EventHandler() { + EventHandler dh_conversion = new EventHandler<>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; @@ -478,7 +480,8 @@ public void handle(DragEvent event) { this.conversionTxt.setOnDragDropped(dh_conversion); this.rdf_fileIcon.setOnDragDetected(new EventHandler() { - public void handle(MouseEvent me) { + @Override + public void handle(MouseEvent me) { if (!IFCtoLBDController.this.rdf_fileIcon.isDisabled()) { Dragboard db = handleOnTxt.startDragAndDrop(TransferMode.ANY); @@ -517,7 +520,8 @@ public void handle(MouseEvent me) { }); this.rdf_fileIcon.setOnDragDone(new EventHandler() { - public void handle(DragEvent me) { + @Override + public void handle(DragEvent me) { me.consume(); } }); @@ -600,7 +604,8 @@ public void handle(DragEvent me) { } - public void handle_notification(String txt) { + @Override + public void handle_notification(String txt) { this.conversionTxt.insertText(0, txt + "\n"); } diff --git a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java index ec9772f8..f360fbaa 100644 --- a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java +++ b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/About.java @@ -62,7 +62,7 @@ public About(Stage owner) root.setEffect(r); Scene scene = new Scene(root, 550.0, 250.0, Color.BLACK); EventHandler ehme; - ehme = new EventHandler() + ehme = new EventHandler<>() { public void handle(MouseEvent event) { diff --git a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java index 685e387e..63557fc7 100644 --- a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java +++ b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ConversionThread.java @@ -61,7 +61,8 @@ public class ConversionThread implements Callable { final boolean hasBoundingBoxWKT; final boolean hasHierarchicalNaming; - public ConversionThread(IFCtoLBDConverter converter,Set selected_types,String ifc_filename, String uriBase, String target_file,int props_level,boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, boolean hasBuildingProperties,boolean hasSeparatePropertiesModel,boolean hasPropertiesBlankNodes, boolean hasGeolocation,boolean hasGeometry,boolean exportIfcOWL,boolean hasUnits,boolean hasPerformanceBoost,boolean hasBoundingBoxWKT,boolean hasHierarchicalNaming) { + //TODO Check this + public ConversionThread(IFCtoLBDConverter converter,Set selected_types,@SuppressWarnings("unused") String ifc_filename, @SuppressWarnings("unused") String uriBase, @SuppressWarnings("unused") String target_file,int props_level,boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, boolean hasBuildingProperties,boolean hasSeparatePropertiesModel,boolean hasPropertiesBlankNodes, boolean hasGeolocation,boolean hasGeometry,boolean exportIfcOWL,boolean hasUnits,boolean hasPerformanceBoost,boolean hasBoundingBoxWKT,boolean hasHierarchicalNaming) { super(); this.converter=converter; this.selected_types=selected_types; @@ -84,6 +85,7 @@ public ConversionThread(IFCtoLBDConverter converter,Set selected_types,S this.hasHierarchicalNaming=hasHierarchicalNaming; } + @Override public Integer call() throws Exception { try { try { diff --git a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java index 89891cd5..ac3af6b6 100644 --- a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java +++ b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/IFCtoLBDController.java @@ -181,14 +181,14 @@ public class IFCtoLBDController implements Initializable, FxInterface { @FXML private CheckTreeView element_types_checkbox; - + @FXML private ToggleSwitch hasHierarchicalNaming; @FXML private void closeApplicationAction() { - eventBus.post(new IFCtoLBD_SystemExit("User selected the application exit.")); - Stage stage = (Stage) myMenuBar.getScene().getWindow(); + this.eventBus.post(new IFCtoLBD_SystemExit("User selected the application exit.")); + Stage stage = (Stage) this.myMenuBar.getScene().getWindow(); stage.close(); System.exit(0); } @@ -196,7 +196,7 @@ private void closeApplicationAction() { @FXML private void aboutAction() { // get a handle to the stage - Stage stage = (Stage) myMenuBar.getScene().getWindow(); + Stage stage = (Stage) this.myMenuBar.getScene().getWindow(); new About(stage).show(); } @@ -257,18 +257,18 @@ public void ifcOWLSelectionChange(MouseEvent event) { @FXML private void selectIFCFile() { - Stage stage = (Stage) myMenuBar.getScene().getWindow(); + Stage stage = (Stage) this.myMenuBar.getScene().getWindow(); File file = null; - if (fc_ifc == null) { - fc_ifc = new FileChooser(); - String work_directory = prefs.get("ifc_work_directory", "."); + if (this.fc_ifc == null) { + this.fc_ifc = new FileChooser(); + String work_directory = this.prefs.get("ifc_work_directory", "."); System.out.println("workdir got:" + work_directory); File fwd = new File(work_directory); - if (fwd != null && fwd.exists()) - fc_ifc.setInitialDirectory(fwd.getParentFile()); + if (fwd.exists()) + this.fc_ifc.setInitialDirectory(fwd.getParentFile()); else - fc_ifc.setInitialDirectory(new File(".")); + this.fc_ifc.setInitialDirectory(new File(".")); } FileChooser.ExtensionFilter ef1; ef1 = new FileChooser.ExtensionFilter("IFC documents (*.ifc)", "*.ifc"); @@ -276,36 +276,35 @@ private void selectIFCFile() { ef2 = new FileChooser.ExtensionFilter("IFC zip documents (*.ifczip)", "*.ifczip"); FileChooser.ExtensionFilter ef3; ef3 = new FileChooser.ExtensionFilter("All Files", "*.*"); - fc_ifc.getExtensionFilters().clear(); - fc_ifc.getExtensionFilters().addAll(ef1, ef2, ef3); + this.fc_ifc.getExtensionFilters().clear(); + this.fc_ifc.getExtensionFilters().addAll(ef1, ef2, ef3); - if (file == null) - file = fc_ifc.showOpenDialog(stage); + file = this.fc_ifc.showOpenDialog(stage); if (file == null) return; - fc_ifc.setInitialDirectory(file.getParentFile()); - labelIFCFile.setText(file.getName()); - ifcFileName = file.getAbsolutePath(); + this.fc_ifc.setInitialDirectory(file.getParentFile()); + this.labelIFCFile.setText(file.getName()); + this.ifcFileName = file.getAbsolutePath(); int i = file.getName().lastIndexOf("."); if (i > 0) { - String target_directory = prefs.get("ifc_target_directory", file.getParentFile().getAbsolutePath()); + String target_directory = this.prefs.get("ifc_target_directory", file.getParentFile().getAbsolutePath()); if (!new File(target_directory).exists()) target_directory = file.getParent(); - if(target_directory.endsWith("\\")) - rdfTargetName = target_directory + file.getName().substring(0, i) + "_LBD.ttl"; + if (target_directory.endsWith("\\")) + this.rdfTargetName = target_directory + file.getName().substring(0, i) + "_LBD.ttl"; else - rdfTargetName = target_directory + File.separator + file.getName().substring(0, i) + "_LBD.ttl"; - labelTargetFile.setText(rdfTargetName); + this.rdfTargetName = target_directory + File.separator + file.getName().substring(0, i) + "_LBD.ttl"; + this.labelTargetFile.setText(this.rdfTargetName); } - if (ifcFileName != null && rdfTargetName != null) { - selectTargetFileButton.setDisable(false); - convert2RDFButton.setDefaultButton(true); - convert2RDFButton.setDisable(false); - System.out.println("workdir put:" + ifcFileName); - prefs.put("ifc_work_directory", ifcFileName); + if (this.ifcFileName != null && this.rdfTargetName != null) { + this.selectTargetFileButton.setDisable(false); + this.convert2RDFButton.setDefaultButton(true); + this.convert2RDFButton.setDisable(false); + System.out.println("workdir put:" + this.ifcFileName); + this.prefs.put("ifc_work_directory", this.ifcFileName); readInIFC(); } - selectIFCFileButton.setDefaultButton(false); + this.selectIFCFileButton.setDefaultButton(false); // rdf_fileIcon.setDisable(false); // rdf_fileIcon.setImage(fileimage); } @@ -317,64 +316,65 @@ private void selectIFCFile() { @FXML private void selectPropertyLevel1() { - level1.setSelected(true); - level2.setSelected(false); - level3.setSelected(false); + this.level1.setSelected(true); + this.level2.setSelected(false); + this.level3.setSelected(false); } @FXML private void selectPropertyLevel2() { - level1.setSelected(false); - level2.setSelected(true); - level3.setSelected(false); + this.level1.setSelected(false); + this.level2.setSelected(true); + this.level3.setSelected(false); } @FXML private void selectPropertyLevel3() { - level1.setSelected(false); - level2.setSelected(false); - level3.setSelected(true); + this.level1.setSelected(false); + this.level2.setSelected(false); + this.level3.setSelected(true); } @FXML private void selectTargetFile() { - Stage stage = (Stage) myMenuBar.getScene().getWindow(); + Stage stage = (Stage) this.myMenuBar.getScene().getWindow(); File file = null; - fc_target = new FileChooser(); - File fwd = new File(rdfTargetName); - fc_target.setInitialFileName(rdfTargetName); + this.fc_target = new FileChooser(); + File fwd = new File(this.rdfTargetName); + this.fc_target.setInitialFileName(this.rdfTargetName); if (!fwd.getParentFile().exists()) { - fc_target.setInitialDirectory(new File(ifcFileName).getParentFile()); - String filename=new File(ifcFileName).getParentFile() + File.pathSeparator + fwd.getName(); - System.out.println("Initial Filename to: "+filename); - fc_target.setInitialFileName(filename); + this.fc_target.setInitialDirectory(new File(this.ifcFileName).getParentFile()); + String filename = new File(this.ifcFileName).getParentFile() + File.pathSeparator + fwd.getName(); + System.out.println("Initial Filename to: " + filename); + this.fc_target.setInitialFileName(filename); System.out.println("SET"); } else - fc_target.setInitialDirectory(fwd.getParentFile()); + this.fc_target.setInitialDirectory(fwd.getParentFile()); FileChooser.ExtensionFilter ef; ef = new FileChooser.ExtensionFilter("All Files", ".ttl"); - fc_ifc.getExtensionFilters().clear(); - fc_ifc.getExtensionFilters().addAll(ef); + this.fc_ifc.getExtensionFilters().clear(); + this.fc_ifc.getExtensionFilters().addAll(ef); try { - file = fc_target.showSaveDialog(stage); + file = this.fc_target.showSaveDialog(stage); } catch (Exception e) { - fwd = new File(rdfTargetName); - System.err.println("fwd parent: " + fwd.getParentFile() + " -> " + new File(ifcFileName).getParentFile()); - System.err.println("path was: " + fc_target.getInitialDirectory().getAbsolutePath()); + fwd = new File(this.rdfTargetName); + System.err.println( + "fwd parent: " + fwd.getParentFile() + " -> " + new File(this.ifcFileName).getParentFile()); + System.err.println("path was: " + this.fc_target.getInitialDirectory().getAbsolutePath()); e.printStackTrace(); } if (file == null) return; - fc_target.setInitialDirectory(file.getParentFile()); - prefs.put("ifc_target_directory", file.getParentFile().getAbsolutePath()); - labelTargetFile.setText(file.getAbsolutePath()); + this.fc_target.setInitialDirectory(file.getParentFile()); + this.prefs.put("ifc_target_directory", file.getParentFile().getAbsolutePath()); + this.labelTargetFile.setText(file.getAbsolutePath()); - rdfTargetName = file.getAbsolutePath(); + this.rdfTargetName = file.getAbsolutePath(); } Future running_read_in; @@ -382,40 +382,41 @@ private void selectTargetFile() { private void readInIFC() { - prefs.putBoolean("lbd_building_elements", this.building_elements.isSelected()); - prefs.putBoolean("lbd_building_elements_separate_file", this.building_elements_separate_file.isSelected()); + this.prefs.putBoolean("lbd_building_elements", this.building_elements.isSelected()); + this.prefs.putBoolean("lbd_building_elements_separate_file", this.building_elements_separate_file.isSelected()); - prefs.putBoolean("lbd_building_props", this.building_props.isSelected()); + this.prefs.putBoolean("lbd_building_props", this.building_props.isSelected()); - prefs.putBoolean("lbd_building_props_blank_nodes", this.building_props_blank_nodes.isSelected()); - prefs.putBoolean("lbd_building_props_separate_file", this.building_props_separate_file.isSelected()); - prefs.put("lbd_props_base_url", this.labelBaseURI.getText()); + this.prefs.putBoolean("lbd_building_props_blank_nodes", this.building_props_blank_nodes.isSelected()); + this.prefs.putBoolean("lbd_building_props_separate_file", this.building_props_separate_file.isSelected()); + this.prefs.put("lbd_props_base_url", this.labelBaseURI.getText()); - prefs.putBoolean("lbd_boundinbox_elements", this.geometry_elements.isSelected()); - prefs.putBoolean("lbd_ifcOWL_elements", this.ifcOWL_elements.isSelected()); - prefs.putBoolean("lbd_createUnits", this.createUnits.isSelected()); + this.prefs.putBoolean("lbd_boundinbox_elements", this.geometry_elements.isSelected()); + this.prefs.putBoolean("lbd_ifcOWL_elements", this.ifcOWL_elements.isSelected()); + this.prefs.putBoolean("lbd_createUnits", this.createUnits.isSelected()); - conversionTxt.setText(""); + this.conversionTxt.setText(""); try { - String uri_base = labelBaseURI.getText().trim(); + String uri_base = this.labelBaseURI.getText().trim(); int props_level = 2; - if (level1.isSelected()) + if (this.level1.isSelected()) props_level = 1; - if (level3.isSelected()) + if (this.level3.isSelected()) props_level = 3; - prefs.putInt("lbd_props_level", props_level); - masker_panel.setVisible(true); - if (running_read_in != null && !running_read_in.isDone()) { + this.prefs.putInt("lbd_props_level", props_level); + this.masker_panel.setVisible(true); + if (this.running_read_in != null && !this.running_read_in.isDone()) { this.conversionTxt.appendText("\nThe last conversion is still running. \n"); return; } - running_read_in = executor.submit(new ReadinInThread(ifcFileName, uri_base, rdfTargetName, props_level, - building_elements.isSelected(), building_elements_separate_file.isSelected(), - building_props.isSelected(), building_props_separate_file.isSelected(), - building_props_blank_nodes.isSelected(), geolocation.isSelected(), geometry_elements.isSelected(), - ifcOWL_elements.isSelected(), ifcOWL_elements.isSelected(), hasPerformanceBoost.isSelected(), - hasBoundingBox_WKT.isSelected())); + this.running_read_in = this.executor.submit(new ReadinInThread(this.ifcFileName, uri_base, + this.rdfTargetName, props_level, this.building_elements.isSelected(), + this.building_elements_separate_file.isSelected(), this.building_props.isSelected(), + this.building_props_separate_file.isSelected(), this.building_props_blank_nodes.isSelected(), + this.geolocation.isSelected(), this.geometry_elements.isSelected(), + this.ifcOWL_elements.isSelected(), this.ifcOWL_elements.isSelected(), + this.hasPerformanceBoost.isSelected(), this.hasBoundingBox_WKT.isSelected())); } catch (Exception e) { Platform.runLater(() -> this.conversionTxt.appendText(e.getMessage())); } @@ -424,64 +425,63 @@ private void readInIFC() { @FXML private void convertIFCToRDF() { - - - - prefs.putBoolean("lbd_building_elements", this.building_elements.isSelected()); - prefs.putBoolean("lbd_building_elements_separate_file", this.building_elements_separate_file.isSelected()); - prefs.putBoolean("lbd_building_props", this.building_props.isSelected()); + this.prefs.putBoolean("lbd_building_elements", this.building_elements.isSelected()); + this.prefs.putBoolean("lbd_building_elements_separate_file", this.building_elements_separate_file.isSelected()); - prefs.putBoolean("lbd_building_props_blank_nodes", this.building_props_blank_nodes.isSelected()); - prefs.putBoolean("lbd_building_props_separate_file", this.building_props_separate_file.isSelected()); - prefs.put("lbd_props_base_url", this.labelBaseURI.getText()); + this.prefs.putBoolean("lbd_building_props", this.building_props.isSelected()); - prefs.putBoolean("lbd_boundinbox_elements", this.geometry_elements.isSelected()); - prefs.putBoolean("lbd_ifcOWL_elements", this.ifcOWL_elements.isSelected()); - prefs.putBoolean("lbd_createUnits", this.createUnits.isSelected()); - prefs.putBoolean("lbd_geolocation", this.geolocation.isSelected()); + this.prefs.putBoolean("lbd_building_props_blank_nodes", this.building_props_blank_nodes.isSelected()); + this.prefs.putBoolean("lbd_building_props_separate_file", this.building_props_separate_file.isSelected()); + this.prefs.put("lbd_props_base_url", this.labelBaseURI.getText()); - conversionTxt.setText(""); + this.prefs.putBoolean("lbd_boundinbox_elements", this.geometry_elements.isSelected()); + this.prefs.putBoolean("lbd_ifcOWL_elements", this.ifcOWL_elements.isSelected()); + this.prefs.putBoolean("lbd_createUnits", this.createUnits.isSelected()); + this.prefs.putBoolean("lbd_geolocation", this.geolocation.isSelected()); + + this.conversionTxt.setText(""); try { - String uri_base = labelBaseURI.getText().trim(); + String uri_base = this.labelBaseURI.getText().trim(); int props_level = 2; - if (level1.isSelected()) + if (this.level1.isSelected()) props_level = 1; - if (level3.isSelected()) + if (this.level3.isSelected()) props_level = 3; - prefs.putInt("lbd_props_level", props_level); - masker_panel.setVisible(true); - if (running_conversion != null && !running_conversion.isDone()) { + this.prefs.putInt("lbd_props_level", props_level); + this.masker_panel.setVisible(true); + if (this.running_conversion != null && !this.running_conversion.isDone()) { this.conversionTxt.appendText("\nThe last conversion is still running. \n"); return; } - - - Set selected_types=new HashSet<>(); - for(TreeItem item:element_types_checkbox.getCheckModel().getCheckedItems()) - { + Set selected_types = new HashSet<>(); + for (TreeItem item : this.element_types_checkbox.getCheckModel().getCheckedItems()) { selected_types.add(item.getValue()); - + } - running_conversion = executor.submit(new ConversionThread(this.running_read_in.get(), selected_types,ifcFileName, uri_base, - rdfTargetName, props_level, building_elements.isSelected(), - building_elements_separate_file.isSelected(), building_props.isSelected(), - building_props_separate_file.isSelected(), building_props_blank_nodes.isSelected(), - geolocation.isSelected(), geometry_elements.isSelected(), ifcOWL_elements.isSelected(), - ifcOWL_elements.isSelected(), hasPerformanceBoost.isSelected(), hasBoundingBox_WKT.isSelected(), hasHierarchicalNaming.isSelected())); + this.running_conversion = this.executor.submit(new ConversionThread(this.running_read_in.get(), + selected_types, this.ifcFileName, uri_base, this.rdfTargetName, props_level, + this.building_elements.isSelected(), this.building_elements_separate_file.isSelected(), + this.building_props.isSelected(), this.building_props_separate_file.isSelected(), + this.building_props_blank_nodes.isSelected(), this.geolocation.isSelected(), this.geometry_elements.isSelected(), + this.ifcOWL_elements.isSelected(), this.ifcOWL_elements.isSelected(), this.hasPerformanceBoost.isSelected(), + this.hasBoundingBox_WKT.isSelected(), this.hasHierarchicalNaming.isSelected())); } catch (Exception e) { Platform.runLater(() -> this.conversionTxt.appendText(e.getMessage())); } } + @SuppressWarnings("unused") + @Override public void initialize(URL location, ResourceBundle resources) { - eventBus.register(this); - border.widthProperty().bind(root.widthProperty()); - border.heightProperty().bind(root.heightProperty()); + this.eventBus.register(this); + this.border.widthProperty().bind(this.root.widthProperty()); + this.border.heightProperty().bind(this.root.heightProperty()); // Accepts dropping new EventHandler() { + @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (db.hasFiles()) { @@ -494,7 +494,7 @@ public void handle(DragEvent event) { }; // Accepts dropping - EventHandler ad_conversion = new EventHandler() { + EventHandler ad_conversion = new EventHandler<>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); if (db.hasFiles()) { @@ -506,22 +506,22 @@ public void handle(DragEvent event) { }; // Dropping over surface - EventHandler dh_conversion = new EventHandler() { + EventHandler dh_conversion = new EventHandler<>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; for (File file : db.getFiles()) { - labelIFCFile.setText(file.getName()); - ifcFileName = file.getAbsolutePath(); - if (ifcFileName != null && rdfTargetName != null) { - convert2RDFButton.setDefaultButton(true); - selectIFCFileButton.setDefaultButton(false); - convert2RDFButton.setDisable(false); + IFCtoLBDController.this.labelIFCFile.setText(file.getName()); + IFCtoLBDController.this.ifcFileName = file.getAbsolutePath(); + if (IFCtoLBDController.this.ifcFileName != null && IFCtoLBDController.this.rdfTargetName != null) { + IFCtoLBDController.this.convert2RDFButton.setDefaultButton(true); + IFCtoLBDController.this.selectIFCFileButton.setDefaultButton(false); + IFCtoLBDController.this.convert2RDFButton.setDisable(false); } - rdf_fileIcon.setDisable(false); - rdf_fileIcon.setImage(fileimage); + IFCtoLBDController.this.rdf_fileIcon.setDisable(false); + IFCtoLBDController.this.rdf_fileIcon.setImage(IFCtoLBDController.this.fileimage); } } event.setDropCompleted(success); @@ -529,14 +529,14 @@ public void handle(DragEvent event) { } }; - selectIFCFileButton.setOnDragOver(ad_conversion); - selectIFCFileButton.setOnDragDropped(dh_conversion); - convert2RDFButton.setOnDragOver(ad_conversion); - convert2RDFButton.setOnDragDropped(dh_conversion); - labelIFCFile.setOnDragOver(ad_conversion); - labelIFCFile.setOnDragDropped(dh_conversion); - conversionTxt.setOnDragOver(ad_conversion); - conversionTxt.setOnDragDropped(dh_conversion); + this.selectIFCFileButton.setOnDragOver(ad_conversion); + this.selectIFCFileButton.setOnDragDropped(dh_conversion); + this.convert2RDFButton.setOnDragOver(ad_conversion); + this.convert2RDFButton.setOnDragDropped(dh_conversion); + this.labelIFCFile.setOnDragOver(ad_conversion); + this.labelIFCFile.setOnDragDropped(dh_conversion); + this.conversionTxt.setOnDragOver(ad_conversion); + this.conversionTxt.setOnDragDropped(dh_conversion); /* * rdf_fileIcon.setOnDragDetected(new EventHandler() { public void @@ -571,21 +571,21 @@ public void handle(DragEvent event) { * rdf_fileIcon.setOnDragDone(new EventHandler() { public void * handle(DragEvent me) { me.consume(); } }); */ - this.labelBaseURI.setText(prefs.get("lbd_props_base_url", "https://www.ugent.be/myAwesomeFirstBIMProject#")); - this.building_elements.setSelected(prefs.getBoolean("lbd_building_elements", true)); + this.labelBaseURI + .setText(this.prefs.get("lbd_props_base_url", "https://www.ugent.be/myAwesomeFirstBIMProject#")); + this.building_elements.setSelected(this.prefs.getBoolean("lbd_building_elements", true)); this.building_elements_separate_file - .setSelected(prefs.getBoolean("lbd_building_elements_separate_file", false)); - this.building_props.setSelected(prefs.getBoolean("lbd_building_props", true)); - this.building_props_blank_nodes.setSelected(prefs.getBoolean("lbd_building_props_blank_nodes", false)); - this.building_props_separate_file.setSelected(prefs.getBoolean("lbd_building_props_separate_file", false)); - - this.geometry_elements.setSelected(prefs.getBoolean("lbd_boundinbox_elements", true)); - this.ifcOWL_elements.setSelected(prefs.getBoolean("lbd_ifcOWL_elements", false)); - this.createUnits.setSelected(prefs.getBoolean("lbd_createUnits", false)); - this.geolocation.setSelected(prefs.getBoolean("lbd_geolocation", true)); - - - this.hasPerformanceBoost.setSelected(prefs.getBoolean("lbd_performance", true)); + .setSelected(this.prefs.getBoolean("lbd_building_elements_separate_file", false)); + this.building_props.setSelected(this.prefs.getBoolean("lbd_building_props", true)); + this.building_props_blank_nodes.setSelected(this.prefs.getBoolean("lbd_building_props_blank_nodes", false)); + this.building_props_separate_file.setSelected(this.prefs.getBoolean("lbd_building_props_separate_file", false)); + + this.geometry_elements.setSelected(this.prefs.getBoolean("lbd_boundinbox_elements", true)); + this.ifcOWL_elements.setSelected(this.prefs.getBoolean("lbd_ifcOWL_elements", false)); + this.createUnits.setSelected(this.prefs.getBoolean("lbd_createUnits", false)); + this.geolocation.setSelected(this.prefs.getBoolean("lbd_geolocation", true)); + + this.hasPerformanceBoost.setSelected(this.prefs.getBoolean("lbd_performance", true)); if (this.ifcOWL_elements.isSelected()) { this.hasPerformanceBoost.setSelected(false); this.hasPerformanceBoost.setDisable(true); @@ -594,52 +594,57 @@ public void handle(DragEvent event) { this.hasPerformanceBoost.setDisable(false); } - int props_level = prefs.getInt("lbd_props_level", 3); + int props_level = this.prefs.getInt("lbd_props_level", 3); switch (props_level) { case 1: - level1.setSelected(true); - level2.setSelected(false); - level3.setSelected(false); + this.level1.setSelected(true); + this.level2.setSelected(false); + this.level3.setSelected(false); break; case 2: - level1.setSelected(false); - level2.setSelected(true); - level3.setSelected(false); + this.level1.setSelected(false); + this.level2.setSelected(true); + this.level3.setSelected(false); break; case 3: - level1.setSelected(false); - level2.setSelected(false); - level3.setSelected(true); + this.level1.setSelected(false); + this.level2.setSelected(false); + this.level3.setSelected(true); + break; + default: + this.level1.setSelected(true); + this.level2.setSelected(false); + this.level3.setSelected(false); break; } - building_elements.setTooltip(new Tooltip( + this.building_elements.setTooltip(new Tooltip( "Building Product Ontology instances. \nThis is described in: https://github.com/w3c-lbd-cg/product")); - building_elements_separate_file.setTooltip(new Tooltip("Create the content in separate files.")); - building_props.setTooltip(new Tooltip( + this.building_elements_separate_file.setTooltip(new Tooltip("Create the content in separate files.")); + this.building_props.setTooltip(new Tooltip( "Building related properties\nThis is dedcribed in: https://github.com/w3c-lbd-cg/lbd/blob/gh-pages/presentations/props/presentation_LBDcall_20180312_final.pdf")); - building_props_separate_file + this.building_props_separate_file .setTooltip(new Tooltip("Create the content in separate files (Only levels 2 or 3).")); - elements_link.setTooltip(new Tooltip("Opens a link that describes the Building Product Ontology.")); + this.elements_link.setTooltip(new Tooltip("Opens a link that describes the Building Product Ontology.")); - props_link.setTooltip(new Tooltip("Opens a link to the Towards a PROPS ontology presentation.")); - opm_link.setTooltip(new Tooltip("Opens a link that describes the Ontology for Property Management.")); + this.props_link.setTooltip(new Tooltip("Opens a link to the Towards a PROPS ontology presentation.")); + this.opm_link.setTooltip(new Tooltip("Opens a link that describes the Ontology for Property Management.")); - selectIFCFileButton.setTooltip(new Tooltip( + this.selectIFCFileButton.setTooltip(new Tooltip( "Select an IFC Step formatted file to convert.\nThe supported IFC versions are\n2x3 TC1 & Final, 4 ADD1, 4 ADD2, 4 ")); - selectTargetFileButton.setTooltip(new Tooltip( + this.selectTargetFileButton.setTooltip(new Tooltip( "Select an target file for the conversion.\nIf there will be many files, the separate files are named accorrdingly.")); - convert2RDFButton.setTooltip(new Tooltip("Press this button to start the conversion process.")); - conversionTxt.setTooltip( + this.convert2RDFButton.setTooltip(new Tooltip("Press this button to start the conversion process.")); + this.conversionTxt.setTooltip( new Tooltip("This shows the conversion process related messages\nand any error that occurs. ")); - labelIFCFile.setTooltip(new Tooltip("The selected IFC file. ")); + this.labelIFCFile.setTooltip(new Tooltip("The selected IFC file. ")); - labelTargetFile.setTooltip(new Tooltip("The selected target RDF file. ")); + this.labelTargetFile.setTooltip(new Tooltip("The selected target RDF file. ")); - labelBaseURI + this.labelBaseURI .setTooltip(new Tooltip("The base URL is the consistent part of your links generated in the output. ")); this.hasPerformanceBoost.setTooltip( @@ -647,8 +652,9 @@ public void handle(DragEvent event) { } + @Override public void handle_notification(String txt) { - conversionTxt.insertText(0, txt + "\n"); + this.conversionTxt.insertText(0, txt + "\n"); } @Subscribe @@ -674,21 +680,20 @@ public void handleEvent(final ProcessReadyEvent event) { try { IFCtoLBDConverter converter = this.running_read_in.get(); Set element_types = converter.getElementTypes(); - CheckBoxTreeItem root = new CheckBoxTreeItem<>("Model"); + CheckBoxTreeItem r = new CheckBoxTreeItem<>("Model"); - root.getChildren().clear(); + r.getChildren().clear(); // add items to the root - for(Resource et:element_types) - { + for (Resource et : element_types) { CheckBoxTreeItem item = new CheckBoxTreeItem<>(et.getLocalName()); item.setSelected(true); - root.getChildren().add(item); - + r.getChildren().add(item); + } - root.setExpanded(true); + r.setExpanded(true); - element_types_checkbox.setRoot(root); - element_types_checkbox.setShowRoot(true); + this.element_types_checkbox.setRoot(r); + this.element_types_checkbox.setShowRoot(true); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { diff --git a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ReadinInThread.java b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ReadinInThread.java index a5d142e8..4c66efa0 100644 --- a/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ReadinInThread.java +++ b/IFCtoLBD_Desktop_2023/src/main/java/org/linkedbuildingdata/ifc2lbd/desktop/ReadinInThread.java @@ -56,7 +56,8 @@ public class ReadinInThread implements Callable { final boolean hasPerformanceBoost; final boolean hasBoundingBoxWKT; - public ReadinInThread(String ifc_filename, String uriBase, String target_file,int props_level,boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, boolean hasBuildingProperties,boolean hasSeparatePropertiesModel,boolean hasPropertiesBlankNodes, boolean hasGeolocation,boolean hasGeometry,boolean exportIfcOWL,boolean hasUnits,boolean hasPerformanceBoost,boolean hasBoundingBoxWKT) { + //TODO Check this + public ReadinInThread(String ifc_filename, String uriBase, String target_file,int props_level,@SuppressWarnings("unused") boolean hasBuildingElements, boolean hasSeparateBuildingElementsModel, @SuppressWarnings("unused") boolean hasBuildingProperties,boolean hasSeparatePropertiesModel,boolean hasPropertiesBlankNodes, boolean hasGeolocation,boolean hasGeometry,boolean exportIfcOWL,boolean hasUnits,boolean hasPerformanceBoost,boolean hasBoundingBoxWKT) { super(); this.ifc_filename = ifc_filename; this.uriBase = uriBase; @@ -76,24 +77,25 @@ public ReadinInThread(String ifc_filename, String uriBase, String target_file,in this.hasBoundingBoxWKT=hasBoundingBoxWKT; } + @Override public IFCtoLBDConverter call() throws Exception { try { IFCtoLBDConverter c1nb; try { - c1nb = new IFCtoLBDConverter(uriBase, false, this.props_level); - c1nb.convert_read_in_phase(ifc_filename,target_file, hasGeometry,hasPerformanceBoost,exportIfcOWL); + c1nb = new IFCtoLBDConverter(this.uriBase, false, this.props_level); + c1nb.convert_read_in_phase(this.ifc_filename,this.target_file, this.hasGeometry,this.hasPerformanceBoost,this.exportIfcOWL); } catch (OutOfMemoryError e) { e.printStackTrace(); - eventBus.post(new IFCtoLBD_SystemStatusEvent(e.getMessage())); - eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.ERROR)); + this.eventBus.post(new IFCtoLBD_SystemStatusEvent(e.getMessage())); + this.eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.ERROR)); return null; } - eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.READ_IN)); + this.eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.READ_IN)); return c1nb; } catch (Exception e) { e.printStackTrace(); - eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.ERROR)); - eventBus.post(new IFCtoLBD_SystemStatusEvent(e.getMessage())); + this.eventBus.post(new ProcessReadyEvent(ProcessReadyEvent.ERROR)); + this.eventBus.post(new IFCtoLBD_SystemStatusEvent(e.getMessage())); } return null; } diff --git a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/OperatingSystemCopyOf_IfcGeomServer.java b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/OperatingSystemCopyOf_IfcGeomServer.java index 9a3f89ad..bd24f687 100644 --- a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/OperatingSystemCopyOf_IfcGeomServer.java +++ b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/OperatingSystemCopyOf_IfcGeomServer.java @@ -10,7 +10,6 @@ public class OperatingSystemCopyOf_IfcGeomServer { - @SuppressWarnings("resource") public static String getIfcGeomServer() { String OS = System.getProperty("os.name").toLowerCase(); diff --git a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/IFCGeometry.java b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/IFCGeometry.java index 32ce75e2..f40d7db5 100644 --- a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/IFCGeometry.java +++ b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/IFCGeometry.java @@ -108,7 +108,7 @@ public BoundingBox getBoundingBox(String guid) { return boundingBox; } - private Point3d processExtends(double[] transformationMatrix, ByteBuffer byteBuffer) { + private static Point3d processExtends(double[] transformationMatrix, ByteBuffer byteBuffer) { double x = byteBuffer.getDouble(); double y = byteBuffer.getDouble(); double z = byteBuffer.getDouble(); @@ -165,7 +165,7 @@ public ObjDescription getOBJ(String guid) { return obj_desc; } - private Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuffer) { + private static Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuffer) { double x = byteBuffer.getDouble(); double y = byteBuffer.getDouble(); double z = byteBuffer.getDouble(); @@ -178,13 +178,13 @@ private Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuff } - private ImmutableTriple processSurface(ByteBuffer byteBuffer) { + private static ImmutableTriple processSurface(ByteBuffer byteBuffer) { int xi = byteBuffer.getInt(); int yi = byteBuffer.getInt(); int zi = byteBuffer.getInt(); - ImmutableTriple point = new ImmutableTriple(xi + 1, + ImmutableTriple point = new ImmutableTriple<>(xi + 1, yi + 1, zi + 1); return point; @@ -192,7 +192,7 @@ private ImmutableTriple processSurface(ByteBuffer byt public static IfcOpenShellEngine ifcOpenShellEngine_singlethon = null; - private IfcOpenShellModel getRenderEngineModel(File ifcFile) { + private static IfcOpenShellModel getRenderEngineModel(File ifcFile) { try { String ifcGeomServerLocation = OperatingSystemCopyOf_IfcGeomServer.getIfcGeomServer(); System.out.println("ifcGeomServerLocation: " + ifcGeomServerLocation); diff --git a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/ObjDescription.java b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/ObjDescription.java index eed69d42..c75df915 100644 --- a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/ObjDescription.java +++ b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/ObjDescription.java @@ -27,18 +27,18 @@ */ public class ObjDescription { - List vertices = new ArrayList(); - List> faces = new ArrayList>(); + List vertices = new ArrayList<>(); + List> faces = new ArrayList<>(); public ObjDescription() { } public void addVertex(Point3d point) { - vertices.add(point); + this.vertices.add(point); } public void addFace(ImmutableTriple face) { - faces.add(face); + this.faces.add(face); } @Override diff --git a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/IFCtoObj.java b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/IFCtoObj.java index e02ed087..c0f2c25d 100644 --- a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/IFCtoObj.java +++ b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/IFCtoObj.java @@ -2,7 +2,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.file.Path; @@ -19,7 +18,6 @@ import org.apache.commons.lang3.tuple.ImmutableTriple; import org.bimserver.geometry.Matrix; -import org.bimserver.plugins.deserializers.DeserializeException; import org.bimserver.plugins.renderengine.RenderEngineException; import org.bimserver.plugins.renderengine.RenderEngineGeometry; import org.ifcopenshell.IfcOpenShellEngine; @@ -34,13 +32,13 @@ public class IFCtoObj { private IfcOpenShellModel renderEngineModel = null; - public IFCtoObj(File ifcFile) throws DeserializeException, IOException, RenderEngineException { + public IFCtoObj(File ifcFile) { ExecutorService executor = Executors.newCachedThreadPool(); - Callable task = new Callable() { + Callable task = new Callable<>() { public IfcOpenShellModel call() { - renderEngineModel = getRenderEngineModel(ifcFile); - return renderEngineModel; + IFCtoObj.this.renderEngineModel = getRenderEngineModel(ifcFile); + return IFCtoObj.this.renderEngineModel; } }; Future future = executor.submit(task); @@ -73,8 +71,7 @@ public ObjDescription getOBJ(String guid) { try { RenderEngineGeometry geometry = renderEngineInstance.generateGeometry(); - - + if (geometry != null && geometry.getIndices().limit() > 0) { obj_desc = new ObjDescription(); double[] tranformationMatrix = new double[16]; @@ -82,22 +79,23 @@ public ObjDescription getOBJ(String guid) { if (renderEngineInstance.getTransformationMatrix() != null) { tranformationMatrix = renderEngineInstance.getTransformationMatrix(); } - + ByteBuffer ver = geometry.getVertices().order(ByteOrder.nativeOrder()); - - while (ver.hasRemaining()) - { + + while (ver.hasRemaining()) { Point3d p = processVertex(tranformationMatrix, ver); obj_desc.addVertex(p); } - - /*for (int i = 0; i < geometry.getNrIndices() / 3; i++) { - ImmutableTriple f = processSurface(geometry.getIndices(), i * 3); - obj_desc.addFace(f); - }*/ + /* + * for (int i = 0; i < geometry.getNrIndices() / 3; i++) { + * ImmutableTriple f = + * processSurface(geometry.getIndices(), i * 3); obj_desc.addFace(f); + * + * } + */ ByteBuffer inx = geometry.getIndices().order(ByteOrder.nativeOrder()); - + while (inx.hasRemaining()) { ImmutableTriple f = processSurface(inx); obj_desc.addFace(f); @@ -110,11 +108,11 @@ public ObjDescription getOBJ(String guid) { return obj_desc; } - private Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuffer) { + private static Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuffer) { double x = byteBuffer.getDouble(); double y = byteBuffer.getDouble(); double z = byteBuffer.getDouble(); - + double[] result = new double[4]; Matrix.multiplyMV(result, 0, transformationMatrix, 0, new double[] { x, y, z, 1 }, 0); @@ -123,37 +121,37 @@ private Point3d processVertex(double[] transformationMatrix, ByteBuffer byteBuff } - private ImmutableTriple processSurface(ByteBuffer byteBuffer) { - - + private static ImmutableTriple processSurface(ByteBuffer byteBuffer) { + int xi = byteBuffer.getInt(); int yi = byteBuffer.getInt(); int zi = byteBuffer.getInt(); - - ImmutableTriple point = new ImmutableTriple(xi + 1, yi + 1, zi + 1); + + ImmutableTriple point = new ImmutableTriple<>(xi + 1, + yi + 1, zi + 1); return point; } - - private IfcOpenShellModel getRenderEngineModel(File ifcFile) { + private static IfcOpenShellModel getRenderEngineModel(File ifcFile) { try { String ifcGeomServerLocation = OperatingSystemCopyOf_IfcGeomServer.getIfcGeomServer(); System.out.println("ifcGeomServerLocation: " + ifcGeomServerLocation); Path ifcGeomServerLocationPath = Paths.get(ifcGeomServerLocation); - if(IFCGeometry.ifcOpenShellEngine_singlethon==null) - { - IFCGeometry.ifcOpenShellEngine_singlethon = new IfcOpenShellEngine(ifcGeomServerLocationPath, false, true); + if (IFCGeometry.ifcOpenShellEngine_singlethon == null) { + IFCGeometry.ifcOpenShellEngine_singlethon = new IfcOpenShellEngine(ifcGeomServerLocationPath, false, + true); IFCGeometry.ifcOpenShellEngine_singlethon.init(); - } FileInputStream ifcFileInputStream = new FileInputStream(ifcFile); - - System.out.println("ifcFile: " + ifcFile); - IfcOpenShellModel model = IFCGeometry.ifcOpenShellEngine_singlethon.openModel(ifcFileInputStream); - System.out.println("IfcOpenShell opens ifc: " + ifcFile.getAbsolutePath()); + } + try (FileInputStream ifcFileInputStream = new FileInputStream(ifcFile);) { - model.generateGeneralGeometry(); - return model; + System.out.println("ifcFile: " + ifcFile); + IfcOpenShellModel model = IFCGeometry.ifcOpenShellEngine_singlethon.openModel(ifcFileInputStream); + System.out.println("IfcOpenShell opens ifc: " + ifcFile.getAbsolutePath()); + model.generateGeneralGeometry(); + return model; + } } catch (Exception e) { e.printStackTrace(); } diff --git a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/ObjGeometryTest.java b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/ObjGeometryTest.java index b7f2a9cc..80bd2998 100644 --- a/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/ObjGeometryTest.java +++ b/IFCtoLBD_Geometry/src/main/java/de/rwth_aachen/dc/lbd/obj/ObjGeometryTest.java @@ -4,24 +4,23 @@ import java.io.FileOutputStream; import java.io.IOException; -import org.bimserver.plugins.deserializers.DeserializeException; -import org.bimserver.plugins.renderengine.RenderEngineException; - import de.rwth_aachen.dc.lbd.ObjDescription; public class ObjGeometryTest { public static void main(String[] args) { try { - IFCtoObj ib=new IFCtoObj(new File("c:\\ifc\\Project1.ifc")); - ObjDescription b=ib.getOBJ("2XR7ZJ3vvFfQ0vDTZymDVE"); - FileOutputStream outputStream = new FileOutputStream("c:\\jo\\test.obj"); - byte[] strToBytes = b.toString().getBytes(); - outputStream.write(strToBytes); - - outputStream.close(); - System.out.println(b); - } catch (RenderEngineException | DeserializeException | IOException e) { + IFCtoObj ib = new IFCtoObj(new File("c:\\ifc\\Project1.ifc")); + ObjDescription b = ib.getOBJ("2XR7ZJ3vvFfQ0vDTZymDVE"); + // JO 2024 + try (FileOutputStream outputStream = new FileOutputStream("c:\\jo\\test.obj");) { + byte[] strToBytes = b.toString().getBytes(); + outputStream.write(strToBytes); + + outputStream.close(); + System.out.println(b); + } + } catch (IOException e) { e.printStackTrace(); } System.exit(1); diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClient.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClient.java index 92c25ca1..6d30ed17 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClient.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClient.java @@ -122,9 +122,8 @@ private static String getExecutableExtension() { final String os = System.getProperty("os.name").toLowerCase(); if (os.contains("windows")) { return ".exe"; - } else { - return ""; } + return ""; } public static Path getExecutablePathFromRepo(Path root) throws PluginException { @@ -242,7 +241,7 @@ private void getExecutable(ExecutableSource source, String commitSha, Path homeD } } - public IfcGeomServerClient(Path executableFilename) throws RenderEngineException { + public IfcGeomServerClient(Path executableFilename) { this.executableFilename = executableFilename; } @@ -573,7 +572,7 @@ void read_contents(LittleEndianDataInputStream s0) throws IOException { readByteBuffer(s), readByteBuffer(s), readByteBuffer(s), readRemainder(bis)); } - private String readRemainder(ByteArrayInputStream bis) { + private static String readRemainder(ByteArrayInputStream bis) { if (bis.available() == 0) { return null; } @@ -583,7 +582,7 @@ private String readRemainder(ByteArrayInputStream bis) { } public IfcGeomServerClientEntity getEntity() { - return entity; + return this.entity; } @Override diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClientEntity.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClientEntity.java index 190ab81f..d26ddbdb 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClientEntity.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcGeomServerClientEntity.java @@ -17,6 +17,9 @@ * along with this program. If not, see {@literal}. *****************************************************************************/ + +// JO 2024 + import java.io.IOException; import java.nio.ByteBuffer; @@ -38,7 +41,6 @@ *****************************************************************************/ import org.bimserver.geometry.Matrix; -import org.bimserver.plugins.renderengine.RenderEngineException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -111,30 +113,30 @@ public double[] getMatrix() { } public int getRepId() { - return repId; + return this.repId; } public ByteBuffer getPositions() { - return positions; + return this.positions; } public ByteBuffer getNormals() { - return normals; + return this.normals; } public ByteBuffer getIndices() { - return indices; + return this.indices; } public ByteBuffer getColors() { - return colors; + return this.colors; } public ByteBuffer getMaterialIndices() { - return materialIndices; + return this.materialIndices; } - public ObjectNode getAllExtendedData() throws RenderEngineException { + public ObjectNode getAllExtendedData() { return this.extendedData; } } \ No newline at end of file diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEngine.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEngine.java index f39e7b62..366de640 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEngine.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEngine.java @@ -26,24 +26,6 @@ package org.ifcopenshell; -/****************************************************************************** - * Copyright (C) 2009-2019 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see {@literal}. - *****************************************************************************/ - -import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; @@ -61,7 +43,7 @@ public class IfcOpenShellEngine implements RenderEngine { private boolean calculateQuantities; private boolean applyLayerSets; - public IfcOpenShellEngine(Path executableFilename, boolean calculateQuantities, boolean applyLayerSets) throws IOException { + public IfcOpenShellEngine(Path executableFilename, boolean calculateQuantities, boolean applyLayerSets) { this.executableFilename = executableFilename; this.setCalculateQuantities(calculateQuantities); this.setApplyLayerSets(applyLayerSets); @@ -71,43 +53,36 @@ public IfcOpenShellEngine(Path executableFilename, boolean calculateQuantities, public void init() throws RenderEngineException { LOGGER.debug("Initializing IfcOpenShell engine"); - client = new IfcGeomServerClient(executableFilename); - client.setCalculateQuantities(isCalculateQuantities()); - client.setApplyLayersets(isApplyLayerSets()); + this.client = new IfcGeomServerClient(this.executableFilename); + this.client.setCalculateQuantities(isCalculateQuantities()); + this.client.setApplyLayersets(isApplyLayerSets()); } @Override public void close() throws RenderEngineException { LOGGER.debug("Closing IfcOpenShell engine"); - if (client.isRunning()) { - client.close(); + if (this.client.isRunning()) { + this.client.close(); } } @Override public IfcOpenShellModel openModel(InputStream inputStream, long size) throws RenderEngineException { - if (!client.isRunning()) { - client = new IfcGeomServerClient(executableFilename); - } - try { - return new IfcOpenShellModel(client, inputStream, size); - } catch (IOException e) { - throw new RenderEngineException(e); + if (!this.client.isRunning()) { + this.client = new IfcGeomServerClient(this.executableFilename); } + return new IfcOpenShellModel(this.client, inputStream, size); } @Override public IfcOpenShellModel openModel(InputStream inputStream) throws RenderEngineException { - if (!client.isRunning()) { - client = new IfcGeomServerClient(executableFilename); - } - try { - return new IfcOpenShellModel(client, inputStream); - } catch (IOException e) { - throw new RenderEngineException(e); + if (!this.client.isRunning()) { + this.client = new IfcGeomServerClient(this.executableFilename); } + return new IfcOpenShellModel(this.client, inputStream); } + @Override public boolean isCalculateQuantities() { return calculateQuantities; } @@ -116,8 +91,9 @@ public void setCalculateQuantities(boolean calculateQuantities) { this.calculateQuantities = calculateQuantities; } + @Override public boolean isApplyLayerSets() { - return applyLayerSets; + return this.applyLayerSets; } public void setApplyLayerSets(boolean applyLayerSets) { diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEnginePlugin.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEnginePlugin.java index e679114d..26b5dd93 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEnginePlugin.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEnginePlugin.java @@ -26,24 +26,6 @@ package org.ifcopenshell; -/****************************************************************************** - * Copyright (C) 2009-2019 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see {@literal}. - *****************************************************************************/ - -import java.io.IOException; import java.nio.file.Path; import org.bimserver.models.store.BooleanType; @@ -77,11 +59,7 @@ public class IfcOpenShellEnginePlugin implements RenderEnginePlugin { @Override public RenderEngine createRenderEngine(PluginConfiguration pluginConfiguration, String schema) throws RenderEngineException { - try { - return new IfcOpenShellEngine(executableFilename, calculateQuantities, applyLayerSets); - } catch (IOException e) { - throw new RenderEngineException(e); - } + return new IfcOpenShellEngine(executableFilename, calculateQuantities, applyLayerSets); } @Override @@ -160,6 +138,7 @@ public ObjectDefinition getSystemSettingsDefinition() { return settings; } + @Override public VersionInfo getVersionInfo() { return versionInfo; } diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEntityInstance.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEntityInstance.java index 259a29fb..4e0a3a4f 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEntityInstance.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellEntityInstance.java @@ -62,6 +62,7 @@ public RenderEngineGeometry generateGeometry() { return new RenderEngineGeometry(entity.getIndices(), entity.getPositions(), entity.getNormals(), entity.getColors(), entity.getMaterialIndices()); } + @Override public ObjectNode getAdditionalData() throws RenderEngineException { return entity.getAllExtendedData(); } diff --git a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellModel.java b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellModel.java index 496fef91..a05e2261 100644 --- a/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellModel.java +++ b/IFCtoLBD_Geometry/src/main/java/org/ifcopenshell/IfcOpenShellModel.java @@ -72,7 +72,7 @@ public class IfcOpenShellModel implements RenderEngineModel { private IfcGeomServerClient client; public IfcOpenShellModel(IfcGeomServerClient client, InputStream ifcInputStream) - throws RenderEngineException, IOException { + throws RenderEngineException { this.client = client; this.ifcInputStream = ifcInputStream; @@ -80,7 +80,7 @@ public IfcOpenShellModel(IfcGeomServerClient client, InputStream ifcInputStream) } public IfcOpenShellModel(IfcGeomServerClient client, InputStream ifcInputStream, long length) - throws RenderEngineException, IOException { + throws RenderEngineException { this.client = client; this.ifcInputStream = ifcInputStream; @@ -89,15 +89,15 @@ public IfcOpenShellModel(IfcGeomServerClient client, InputStream ifcInputStream, @Override public void close() throws RenderEngineException { - if (instancesById != null) { - instancesById.clear(); + if (this.instancesById != null) { + this.instancesById.clear(); } // JO 2020 - if (instancesByGUID != null) { - instancesByGUID.clear(); + if (this.instancesByGUID != null) { + this.instancesByGUID.clear(); } try { - ifcInputStream.close(); + this.ifcInputStream.close(); } catch (IOException e) { LOGGER.error("", e); } @@ -106,35 +106,34 @@ public void close() throws RenderEngineException { @Override public void generateGeneralGeometry() throws RenderEngineException { // We keep track of instances ourselves - instancesById = new HashMap(); - instancesByGUID = new HashMap(); + this.instancesById = new HashMap<>(); + this.instancesByGUID = new HashMap<>(); - final double t0 = (double) System.nanoTime(); + final double t0 = System.nanoTime(); - while (client.hasNext()) { - IfcGeomServerClientEntity next = client.getNext(); + while (this.client.hasNext()) { + IfcGeomServerClientEntity next = this.client.getNext(); // Store the instance in our dictionary IfcOpenShellEntityInstance instance = new IfcOpenShellEntityInstance(next); - instancesById.put(next.getId(), instance); - instancesByGUID.put(next.getGuid(), instance); + this.instancesById.put(next.getId(), instance); + this.instancesByGUID.put(next.getGuid(), instance); } - final double t1 = (double) System.nanoTime(); + final double t1 = System.nanoTime(); LOGGER.debug(String.format("Took %.2f seconds to obtain representations for %d entities", (t1 - t0) / 1.E9, - instancesById.size())); + this.instancesById.size())); } @Override public RenderEngineInstance getInstanceFromExpressId(long expressId) throws RenderEngineException { - if (instancesById.containsKey(expressId)) { - return instancesById.get(expressId); - } else { - // Probably something went wrong with the processing of this element in - // the IfcOpenShell binary, as it has not been included in the enumerated - // set of elements with geometry. - throw new EntityNotFoundException("Entity " + expressId + " not found in model"); + if (this.instancesById.containsKey(expressId)) { + return this.instancesById.get(expressId); } + // Probably something went wrong with the processing of this element in + // the IfcOpenShell binary, as it has not been included in the enumerated + // set of elements with geometry. + throw new EntityNotFoundException("Entity " + expressId + " not found in model"); } @Override @@ -158,10 +157,9 @@ public Collection listInstances() throws RenderEngineExcep } public IfcOpenShellEntityInstance getInstanceFromGUID(String guid) { - if (instancesByGUID.containsKey(guid)) { - return instancesByGUID.get(guid); - } else { - return null; + if (this.instancesByGUID.containsKey(guid)) { + return this.instancesByGUID.get(guid); } + return null; } } \ No newline at end of file diff --git a/IFCtoLBD_OpenAPI/src/main/java/de/rwth_aachen/dc/ifc2lbd/rest/IFCtoLBD_OpenAPI.java b/IFCtoLBD_OpenAPI/src/main/java/de/rwth_aachen/dc/ifc2lbd/rest/IFCtoLBD_OpenAPI.java index 3bc602c7..7b35c4c5 100644 --- a/IFCtoLBD_OpenAPI/src/main/java/de/rwth_aachen/dc/ifc2lbd/rest/IFCtoLBD_OpenAPI.java +++ b/IFCtoLBD_OpenAPI/src/main/java/de/rwth_aachen/dc/ifc2lbd/rest/IFCtoLBD_OpenAPI.java @@ -79,7 +79,7 @@ public Response convertIFCtoLBD(@HeaderParam(HttpHeaders.ACCEPT) String accept_t } - private void extractIFCtoLBD(File ifcFile, StringBuilder result_string, RDFFormat rdfformat) { + private static void extractIFCtoLBD(File ifcFile, StringBuilder result_string, RDFFormat rdfformat) { IFCtoLBDConverter lbdconverter = new IFCtoLBDConverter("https://dot.dc.rwth-aachen.de/IFCtoLBDset", false, 3); Model m = lbdconverter.convert(ifcFile.getAbsolutePath()); @@ -96,6 +96,7 @@ public void write(int b) throws IOException { this.string.append((char) b); } + @Override public String toString() { return this.string.toString(); } diff --git a/IFCtoRDF/src/main/java/be/ugent/IfcSpfParser.java b/IFCtoRDF/src/main/java/be/ugent/IfcSpfParser.java index 1b249a3a..41919465 100644 --- a/IFCtoRDF/src/main/java/be/ugent/IfcSpfParser.java +++ b/IFCtoRDF/src/main/java/be/ugent/IfcSpfParser.java @@ -114,13 +114,12 @@ private void parseIfcLineStatement(String line) { sb.setLength(0); state = Integer.MAX_VALUE; // line is done continue; - } else { - if (sb.toString().trim().length() > 0) - current.add(sb.toString().trim()); - sb.setLength(0); - clCount--; - current = listStack.pop(); } + if (sb.toString().trim().length() > 0) + current.add(sb.toString().trim()); + sb.setLength(0); + clCount--; + current = listStack.pop(); } else if (ch == ',') { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); @@ -223,8 +222,8 @@ public boolean mapEntries() { tmpList.set(j, "-"); continue; //return true; // JO 2022-05 - } else - tmpList.set(j, or); + } + tmpList.set(j, or); } else { // list/set of values tmpList.set(j, s); @@ -249,8 +248,8 @@ public boolean mapEntries() { tmp2List.set(j2, "-"); continue; //return true; // JO 2022-05 - } else - tmp2List.set(j2, or); + } + tmp2List.set(j2, or); } } } @@ -263,7 +262,7 @@ public boolean mapEntries() { return true; } - private Long toLong(String txt) { + private static Long toLong(String txt) { try { return Long.valueOf(txt); } catch (NumberFormatException e) { diff --git a/IFCtoRDF/src/main/java/be/ugent/IfcSpfReader.java b/IFCtoRDF/src/main/java/be/ugent/IfcSpfReader.java index fc3d2112..f7ce11c4 100644 --- a/IFCtoRDF/src/main/java/be/ugent/IfcSpfReader.java +++ b/IFCtoRDF/src/main/java/be/ugent/IfcSpfReader.java @@ -201,8 +201,7 @@ private static String getExpressSchema(String ifcFile) { return "IFC4x1"; if (strLine.indexOf("IFC4") != -1) // Should do also IFC4X2 return "IFC4_ADD2"; //JO 2020 to enable IFCPOLYGONALFACESET that was found in an IFC4 model - else - return ""; + return ""; } } } diff --git a/IFCtoRDF/src/main/java/be/ugent/RDFWriter.java b/IFCtoRDF/src/main/java/be/ugent/RDFWriter.java index d6d96891..61ba6c02 100644 --- a/IFCtoRDF/src/main/java/be/ugent/RDFWriter.java +++ b/IFCtoRDF/src/main/java/be/ugent/RDFWriter.java @@ -15,7 +15,6 @@ */ package be.ugent; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; @@ -93,7 +92,7 @@ public RDFWriter(OntModel ontModel, InputStream inputStream, String baseURI, Map } - public void parseModel2Stream(OutputStream out) throws IOException { + public void parseModel2Stream(OutputStream out) { // CHANGED: Jena 3.16.0 JO: 2020, added Context.emptyContext // 2021/12/10 The Context.emptyContext was not supported in Jena [4.2.0,) ttlWriter = StreamRDFWriter.getWriterStream(out, RDFFormat.TURTLE_BLOCKS, Context.emptyContext()); diff --git a/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/ExpressReader.java b/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/ExpressReader.java index 714e5de2..d4acc567 100644 --- a/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/ExpressReader.java +++ b/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/ExpressReader.java @@ -43,7 +43,7 @@ */ /* - * Copyright 2016 Pieter Pauwels, Ghent University; Jyrki Oraskari, Aalto University; Lewis John McGibbney, Apache + * Copyright 2016, 2024 Pieter Pauwels, Ghent University; Jyrki Oraskari, Aalto University; Lewis John McGibbney, Apache * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,7 +140,7 @@ public void readAndBuild(){ } } - public static void main(String[] args) throws IOException { + public static void main(String[] args) { // args should be: IFC2X3_Final, IFC2X3_TC1, IFC4 or IFC4_ADD1, nothing // else is accepted here if (args.length != 2) @@ -203,8 +203,8 @@ public static void main(String[] args) throws IOException { } } - private void generateNamedIndividualsWithoutRenaming() throws IOException { - for (Map.Entry entry : types.entrySet()) { + private void generateNamedIndividualsWithoutRenaming() { + for (Map.Entry entry : this.types.entrySet()) { TypeVO vo = entry.getValue(); for (int n = 0; n < vo.getEnumEntities().size(); n++) { getEnumIndividuals().add(new NamedIndividualVO(vo.getName(), vo @@ -213,9 +213,9 @@ private void generateNamedIndividualsWithoutRenaming() throws IOException { } } - private void rearrangeAttributesWithFullRenaming() throws IOException { + private void rearrangeAttributesWithFullRenaming() { - Iterator> iter = entities.entrySet().iterator(); + Iterator> iter = this.entities.entrySet().iterator(); while (iter.hasNext()) { Entry pairs = iter.next(); EntityVO evo = pairs.getValue(); @@ -448,15 +448,14 @@ private void outputEntitiesAndTypes(String filePathNoExt, String schemaName) { //JO 2024 fos = new FileOutputStream(filePath+"ent"+schemaName+".ser"); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(entities); - oos.close(); - + try (ObjectOutputStream oos1 = new ObjectOutputStream(fos)) { + oos1.writeObject(this.entities); + } fos = new FileOutputStream(filePath+"typ"+schemaName+".ser"); - oos = new ObjectOutputStream(fos); - oos.writeObject(types); - oos.close(); + try (ObjectOutputStream oos2 = new ObjectOutputStream(fos)) { + oos2.writeObject(this.types); + } } catch (IOException e) { e.printStackTrace(); } @@ -479,29 +478,30 @@ private void outputEntityPropertyList(String filePathNoExt, String schemaName){ try { File file = new File(filePath+"proplist"+schemaName+".csv"); FileWriter fw = new FileWriter(file); - BufferedWriter bw = new BufferedWriter(fw); - - Iterator> it = entities.entrySet().iterator(); - while (it.hasNext()) { - Entry pairs = it.next(); - EntityVO evo = pairs.getValue(); - List attrs = evo.getDerivedAttributeList(); - for(AttributeVO attr : attrs){ - String setorlist = "ENTITY"; - if(attr.isSet()) - setorlist = "SET"; - else if (attr.isArray()) - setorlist = "ARRAY"; - else if (attr.isListOfList()) - setorlist = "LISTOFLIST"; - else if (attr.isList()) - setorlist = "LIST"; - - bw.write(evo.getName() + "," + attr.getOriginalName() + "," + attr.getName() + "," + setorlist + "\r\n"); + try (BufferedWriter bw = new BufferedWriter(fw)) { // JO 2024 + Iterator> it = this.entities.entrySet().iterator(); + while (it.hasNext()) { + Entry pairs = it.next(); + EntityVO evo = pairs.getValue(); + List attrs = evo.getDerivedAttributeList(); + for(AttributeVO attr : attrs){ + String setorlist = "ENTITY"; + if(attr.isSet()) + setorlist = "SET"; + else if (attr.isArray()) + setorlist = "ARRAY"; + else if (attr.isListOfList()) + setorlist = "LISTOFLIST"; + else if (attr.isList()) + setorlist = "LIST"; + + bw.write(evo.getName() + "," + attr.getOriginalName() + "," + attr.getName() + "," + setorlist + "\r\n"); + } + bw.flush(); } - bw.flush(); - } - bw.close(); + bw.close(); + } + fw.close(); } catch (IOException e) { e.printStackTrace(); @@ -590,10 +590,10 @@ public static String formatProperty(String s, boolean isList) { if (isList) return s + "_List"; - else - return s; + return s; } + @SuppressWarnings("unused") private void stateMachine(String txt) { switch (state) { @@ -645,73 +645,73 @@ else if (txt.startsWith("SET") formatClassName(txt).equalsIgnoreCase("BOOLEAN") || formatClassName(txt).equalsIgnoreCase("STRING") || formatClassName(txt).equalsIgnoreCase("BINARY")) new PrimaryTypeVO(formatClassName(txt)); - state = INIT_STATE; + this.state = INIT_STATE; } txt = formatClassName(txt); } else { // references to TypeVOs if (txt.endsWith(";")) txt = txt.substring(0, txt.length() - 1); - state = INIT_STATE; + this.state = INIT_STATE; } - current_type.setPrimarytype(txt); + this.current_type.setPrimarytype(txt); break; case TYPE_ARRAY: if (!txt.endsWith(";")) { - if (current_type != null) - current_type.setPrimarytype(current_type.getPrimarytype() + if (this.current_type != null) + this.current_type.setPrimarytype(this.current_type.getPrimarytype() + " " + txt); } else { - if (current_type != null) - current_type.setPrimarytype(current_type.getPrimarytype() + if (this.current_type != null) + this.current_type.setPrimarytype(this.current_type.getPrimarytype() + " " + txt); - state = INIT_STATE; + this.state = INIT_STATE; } break; case TYPE_LIST: if (!txt.endsWith(";")) { - if (current_type != null) - current_type.setPrimarytype(current_type.getPrimarytype() + if (this.current_type != null) + this.current_type.setPrimarytype(this.current_type.getPrimarytype() + " " + txt); } else { - if (current_type != null) - current_type.setPrimarytype(current_type.getPrimarytype() + if (this.current_type != null) + this.current_type.setPrimarytype(this.current_type.getPrimarytype() + " " + txt); - state = INIT_STATE; + this.state = INIT_STATE; } break; case TYPE_SELECT: if (txt.endsWith(";")) { String txtT = filterExtras(txt); - if (current_type != null) - current_type.getSelectEntities().add(txtT); - state = INIT_STATE; + if (this.current_type != null) + this.current_type.getSelectEntities().add(txtT); + this.state = INIT_STATE; } else { String txtT = filterExtras(txt); - if (current_type != null) - current_type.getSelectEntities().add(txtT); + if (this.current_type != null) + this.current_type.getSelectEntities().add(txtT); } break; case TYPE_ENUMERATION: if ("OF".equals(txt)) { - state = TYPE_ENUMERATION_OF; + this.state = TYPE_ENUMERATION_OF; } break; case TYPE_ENUMERATION_OF: if (txt.endsWith(";")) { String txtT = formatClassName(txt); - if (current_type != null) - current_type.getEnumEntities().add(txtT); - state = INIT_STATE; + if (this.current_type != null) + this.current_type.getEnumEntities().add(txtT); + this.state = INIT_STATE; } else { String txtT = formatClassName(txt); - if (current_type != null) - current_type.getEnumEntities().add(txtT); + if (this.current_type != null) + this.current_type.getEnumEntities().add(txtT); } break; @@ -722,36 +722,36 @@ else if (txt.startsWith("SET") if (orgName.endsWith(";")) orgName = orgName.substring(0, orgName.length() - 1); String entityName = ExpressReader.formatClassName(orgName); - current_entity = entities.get(entityName); - if (current_entity == null) { - current_entity = new EntityVO(orgName); - entities.put(entityName, current_entity); + this.current_entity = this.entities.get(entityName); + if (this.current_entity == null) { + this.current_entity = new EntityVO(orgName); + this.entities.put(entityName, this.current_entity); } - state = ENTITY_STATE; + this.state = ENTITY_STATE; break; case ENTITY_STATE: - is_array = false; - is_set = false; - is_list = false; - is_optional = false; - tmp_mincard = 0; - tmp_maxcard = -1; - is_listoflist = false; - tmp_listoflist_mincard = 0; - tmp_listoflist_maxcard = -1; + this.is_array = false; + this.is_set = false; + this.is_list = false; + this.is_optional = false; + this.tmp_mincard = 0; + this.tmp_maxcard = -1; + this.is_listoflist = false; + this.tmp_listoflist_mincard = 0; + this.tmp_listoflist_maxcard = -1; if (txt.equalsIgnoreCase("SUBTYPE")) { - state = ENTITY_SUBTYPE_STATE; + this.state = ENTITY_SUBTYPE_STATE; } else if (txt.equalsIgnoreCase("SUPERTYPE")) { - state = ENTITY_SUPERTYPE; + this.state = ENTITY_SUPERTYPE; } else if (txt.equalsIgnoreCase("ABSTRACT")) { - current_entity.setAbstractSuperclass(true); - state = ENTITY_SUPERTYPE; + this.current_entity.setAbstractSuperclass(true); + this.state = ENTITY_SUPERTYPE; } else if (txt.equalsIgnoreCase("INVERSE")) { - state = ENTITY_INVERSE_STATE; + this.state = ENTITY_INVERSE_STATE; } else if (txt.equalsIgnoreCase("UNIQUE")) { - state = ENTITY_UNIQUE; + this.state = ENTITY_UNIQUE; } else if (txt.equalsIgnoreCase("WHERE")) { state = ENTITY_WHERE; } else if (txt.equalsIgnoreCase("DERIVE")) { diff --git a/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/OWLWriter.java b/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/OWLWriter.java index a6d3a9e8..caeb16b9 100644 --- a/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/OWLWriter.java +++ b/IFCtoRDF/src/main/java/com/buildingsmart/tech/ifcowl/OWLWriter.java @@ -33,7 +33,7 @@ */ /* - * Copyright 2016 Pieter Pauwels, Ghent University; Jyrki Oraskari, Aalto University; Lewis John McGibbney, Apache + * Copyright 2016, 2024 Pieter Pauwels, Ghent University; Jyrki Oraskari, Aalto University; Lewis John McGibbney, Apache * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,8 +74,8 @@ public OWLWriter(String expressSchemaName, Map entities, Map .\r\n"); out.write("@prefix : <" + Namespace.IFC + "#> .\r\n"); out.write("@prefix ifc: <" + Namespace.IFC + "#> .\r\n"); @@ -94,7 +94,6 @@ public void outputOWL(String filePath) { outputOWLproperty(out, property); } - out.close(); } catch (IOException e) { e.printStackTrace(); @@ -102,8 +101,8 @@ public void outputOWL(String filePath) { } public void outputExpressOWL(String filePath) { - try { - BufferedWriter out = new BufferedWriter(new FileWriter(filePath)); //includes .ttl + // JO 2024 + try (BufferedWriter out = new BufferedWriter(new FileWriter(filePath))) { out.write("@base <" + Namespace.EXPRESS + "> .\r\n"); out.write("@prefix : <" + Namespace.EXPRESS + "#> .\r\n"); out.write("@prefix expr: <" + Namespace.EXPRESS + "#> .\r\n"); @@ -112,7 +111,6 @@ public void outputExpressOWL(String filePath) { writePrimaryTypes(out); writeHelperClasses(out); - out.close(); } catch (IOException e) { e.printStackTrace(); @@ -284,8 +282,8 @@ else if (property.isSet()) } } - private void writePrimaryTypes(BufferedWriter out) throws IOException { - HashMap hm = new HashMap(); + private static void writePrimaryTypes(BufferedWriter out) throws IOException { + HashMap hm = new HashMap<>(); for (PrimaryTypeVO pt : PrimaryTypeVO.getListOfPrimaryTypes()) { // if (pt.getPTypeName().equalsIgnoreCase("BOOLEAN")) { // out.write("express:" + pt.getPTypeName() + "\r\n"); @@ -379,7 +377,7 @@ private void writeNamedIndividuals(BufferedWriter out) throws IOException { } } - private void writeHelperClasses(BufferedWriter out) throws IOException { + private static void writeHelperClasses(BufferedWriter out) throws IOException { // enumeration class out.write("expr:ENUMERATION" + "\r\n"); out.write("\trdf:type owl:Class ." + "\r\n\r\n"); @@ -483,7 +481,7 @@ private void writeEntitiesToOWL(Iterator> it, BufferedWr } } - private void writeRegularProperty(AttributeVO attr, BufferedWriter out) throws IOException { + private static void writeRegularProperty(AttributeVO attr, BufferedWriter out) throws IOException { // write property range out.write(" ;\r\n"); out.write("\trdfs:subClassOf" + "\r\n");// @@ -586,7 +584,7 @@ else if (attr.isList() && !attr.isSet()) } } - private void writeInverseProperty(PropertyVO prop, BufferedWriter out) throws IOException { + private static void writeInverseProperty(PropertyVO prop, BufferedWriter out) throws IOException { out.write(" ;\r\n"); out.write("\trdfs:subClassOf" + "\r\n"); out.write("\t\t[" + "\r\n"); @@ -735,7 +733,7 @@ private void writeEnumerations(TypeVO tvo, BufferedWriter out) throws IOExceptio out.write("\trdfs:subClassOf expr:ENUMERATION ." + "\r\n\r\n"); } - private void writeSelects(TypeVO tvo, BufferedWriter out) throws IOException { + private static void writeSelects(TypeVO tvo, BufferedWriter out) throws IOException { out.write("ifc:" + tvo.getName() + "\r\n"); out.write("\trdf:type owl:Class ;" + "\r\n"); if (tvo.getParentSelectTypes() != null) { @@ -946,7 +944,7 @@ private void writeArrayTypeVO(TypeVO tvo, BufferedWriter out) throws IOException } } - private void writeSetTypeVO(TypeVO tvo, BufferedWriter out) throws IOException { + private static void writeSetTypeVO(TypeVO tvo, BufferedWriter out) throws IOException { String[] cList = tvo.getPrimarytype().split(" "); String content = cList[cList.length - 1]; if (content.endsWith(";")) @@ -987,7 +985,7 @@ private void writeSetTypeVO(TypeVO tvo, BufferedWriter out) throws IOException { out.write("\t\t] ." + "\r\n" + "\r\n"); } - private void writeRegularTypeVO(TypeVO tvo, BufferedWriter out) throws IOException { + private static void writeRegularTypeVO(TypeVO tvo, BufferedWriter out) throws IOException { out.write("ifc:" + tvo.getName() + "\r\n"); out.write("\trdf:type owl:Class ;" + "\r\n"); @@ -1161,7 +1159,7 @@ private String getExpressOwlHeader() { return s; } - private void writeCardinalityRestrictionsForArray(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { + private static void writeCardinalityRestrictionsForArray(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { // write cardinality restrictions for the referenced array if ((minCard == -1 && maxCard == -1) || (minCard != -1 && maxCard == -1) || (minCard == -1 && maxCard != -1)) { System.out.println("WARNING - IMPOSSIBLE: did not find required cardinality restrictions for ARRAY property : " + attrName); @@ -1177,7 +1175,7 @@ private void writeCardinalityRestrictionsForArray(int minCard, int maxCard, Stri } } - private void writeCardinalityRestrictionsForList(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { + private static void writeCardinalityRestrictionsForList(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { if (minCard == -1 && maxCard == -1) { System.out.println("WARNING: [?,?] found for : " + attrName + " - " + className); } else if (minCard == -1 && maxCard != -1) { @@ -1217,7 +1215,7 @@ private void writeCardinalityRestrictionsForList(int minCard, int maxCard, Strin } } - private void writeCardinalityRestrictionsForListOfList(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { + private static void writeCardinalityRestrictionsForListOfList(int minCard, int maxCard, String className, String attrName, BufferedWriter out, boolean asEntity) throws IOException { // write cardinality restrictions for the referenced list if (minCard == -1 && maxCard == -1) { @@ -1267,7 +1265,7 @@ private void writeCardinalityRestrictionsForListOfList(int minCard, int maxCard, } @SuppressWarnings("unused") - private void writeQualCardRestr(String className, String attrName, BufferedWriter out, int qualCard) throws IOException { + private static void writeQualCardRestr(String className, String attrName, BufferedWriter out, int qualCard) throws IOException { out.write(" ;\r\n"); out.write("\trdfs:subClassOf" + "\r\n"); out.write("\t\t[" + "\r\n"); @@ -1300,7 +1298,7 @@ private void writeQualCardRestr(String className, String attrName, BufferedWrite out.write("\t\t]"); } - private void writeMinCardRestr(String className, String attrName, BufferedWriter out, int minCard, boolean asEntity) throws IOException { + private static void writeMinCardRestr(String className, String attrName, BufferedWriter out, int minCard, boolean asEntity) throws IOException { out.write(" ;\r\n"); out.write("\trdfs:subClassOf" + "\r\n"); String tab = "\t"; @@ -1328,7 +1326,7 @@ private void writeMinCardRestr(String className, String attrName, BufferedWriter } } - private void writeMaxCardRestr(String className, String attrName, BufferedWriter out, int maxCard, boolean asEntity) throws IOException { + private static void writeMaxCardRestr(String className, String attrName, BufferedWriter out, int maxCard, boolean asEntity) throws IOException { out.write(" ;\r\n"); out.write("\trdfs:subClassOf" + "\r\n"); String tab = "\t"; @@ -1366,7 +1364,7 @@ private void writeMaxCardRestr(String className, String attrName, BufferedWriter } @SuppressWarnings("unused") - private void writeExtraCardinalityRestrictionsForListOfList(AttributeVO attr, BufferedWriter out) throws IOException { + private static void writeExtraCardinalityRestrictionsForListOfList(AttributeVO attr, BufferedWriter out) throws IOException { if (attr.getMinCardListOfList() == -1 && attr.getMaxCardListOfList() == -1) { System.out.println("WARNING: [?,?] found for : " + attr.getLowerCaseName() + " - " + attr.getType().getName()); } else if (attr.getMinCardListOfList() == -1 && attr.getMaxCardListOfList() != -1) { diff --git a/IFCtoRDF/src/test/java/be/ugent/TestIfcSpfReader.java b/IFCtoRDF/src/test/java/be/ugent/TestIfcSpfReader.java index 4433624f..99abb152 100644 --- a/IFCtoRDF/src/test/java/be/ugent/TestIfcSpfReader.java +++ b/IFCtoRDF/src/test/java/be/ugent/TestIfcSpfReader.java @@ -126,7 +126,7 @@ public final void testConvertIFCFileToOutputTTL() throws IOException { * if there is an error loading method parameters * @throws URISyntaxException */ - private boolean compareFileContents(String testInputTTL, String testOutputTTL) throws IOException { + private static boolean compareFileContents(String testInputTTL, String testOutputTTL) throws IOException { FileInputStream finInput = new FileInputStream(testInputTTL); @SuppressWarnings("resource") BufferedReader brInput = new BufferedReader(new InputStreamReader(finInput)); @@ -147,9 +147,8 @@ private boolean compareFileContents(String testInputTTL, String testOutputTTL) t if (sbInput.toString().equals(sbOutput.toString())) { return true; - } else { - return false; } + return false; } /**