Skip to content

Commit

Permalink
Merge pull request #89 from jyrkioraskari/master
Browse files Browse the repository at this point in the history
Code quality
  • Loading branch information
jyrkioraskari authored Jan 16, 2024
2 parents 20dcee2 + 6a102da commit e82e7d2
Show file tree
Hide file tree
Showing 31 changed files with 556 additions and 629 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ IFCtoLBD_CLI.jar
IFCtoLBD_Desktop.jar
IFCtoRDF/src/main/java/be/ugent/RDFWriter.java
IFCtoLBD_Geometry/.eclipse-pmd
.idea/modules.xml
.idea/IFCtoLBD.iml
.idea/misc.xml
.idea/vcs.xml
.idea/workspace.xml
.idea/*
IFCtoRDF/.eclipse-pmd
IFCtoLBD/.eclipse-pmd
IFCtoLBD/.idea/*
9 changes: 9 additions & 0 deletions IFCProps2ExcelOnline/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -29,9 +30,17 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="target/generated-resources/gwt">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Expand Down
43 changes: 32 additions & 11 deletions IFCProps2ExcelOnline/.settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">







Expand Down Expand Up @@ -29,7 +31,9 @@


<wb-module deploy-name="IFCProps2ExcelOnline-2.43.4">







Expand Down Expand Up @@ -59,7 +63,9 @@


<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>







Expand Down Expand Up @@ -89,7 +95,9 @@


<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>







Expand Down Expand Up @@ -119,7 +127,9 @@


<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>







Expand Down Expand Up @@ -149,16 +159,19 @@


<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-resources/gwt"/>
<dependent-module archiveName="ifc-to-lbd-2.43.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/IFCtoLBD/IFCtoLBD">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="idc_to_lbd_geometry-2.43.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/IFCtoLBD_Geometry/IFCtoLBD_Geometry">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="ifc2rdf-1.3.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/IFCtoRDF/IFCtoRDF">
<dependent-module archiveName="ifc2rdf-1.3.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/IFC2RDF/IFC2RDF">
<dependency-type>uses</dependency-type>
</dependent-module>







Expand Down Expand Up @@ -188,7 +201,9 @@


<property name="java-output-path" value="/mvdXMLOnlineChecker/target/classes"/>







Expand Down Expand Up @@ -218,7 +233,9 @@


<property name="component.exclusion.patterns" value="WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**"/>







Expand All @@ -240,7 +257,9 @@


<property name="context-root" value="IFCProps2ExcelOnline"/>







Expand Down Expand Up @@ -270,7 +289,9 @@


</wb-module>







Expand Down
2 changes: 2 additions & 0 deletions IFCtoLBD/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
Expand All @@ -22,6 +23,7 @@
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
Expand Down
2 changes: 1 addition & 1 deletion IFCtoLBD/src/license/THIRD-PARTY.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
# Please fill the missing licenses for dependencies :
#
#
#Fri Jan 05 16:59:37 CET 2024
#Fri Jan 12 18:11:58 CET 2024
gnu.getopt--java-getopt--1.0.13=
11 changes: 6 additions & 5 deletions IFCtoLBD/src/main/java/examples/Example3.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ public static void main(String[] args) {
IFCtoLBDConverter converter = new IFCtoLBDConverter("https://example.com/", false, 1);
Model model = converter.convert(ifcFile.getAbsolutePath());

Query query = QueryFactory.create("PREFIX bot: <https://w3id.org/bot#>\r\n"
+ "\r\n"
+ "SELECT ?element WHERE {\r\n"
+ " ?element a bot:Element .\r\n"
+ "} ");
Query query = QueryFactory.create("""
PREFIX bot: <https://w3id.org/bot#>\r
\r
SELECT ?element WHERE {\r
?element a bot:Element .\r
}\s""");
try (QueryExecution queryExecution = QueryExecutionFactory.create(query, model)) {
ResultSet resultSet = queryExecution.execSelect();
resultSet.forEachRemaining(qs -> {
Expand Down
15 changes: 8 additions & 7 deletions IFCtoLBD/src/main/java/examples/Example4.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public static void main(String[] args) {
Model m=c.convert(ifc_file.getAbsoluteFile().toString(), null, hasBuildingElements, hasSeparateBuildingElementsModel, hasBuildingProperties, hasSeparatePropertiesModel, hasGeolocation, hasGeometry,exportIfcOWL,hasUnits,hasPerformanceBoost,hasBoundingBoxWKT);
if(m!=null)
{
Query query = QueryFactory.create("PREFIX fog: <https://w3id.org/fog#>\r\n"
+ "\r\n"
+ "SELECT ?e ?wkt ?obj WHERE {\r\n"
+ " ?e <https://w3id.org/omg#hasGeometry> ?g .\r\n"
+ " ?g <https://www.opengis.net/ont/geosparql#asWKT> ?wkt .\r\n"
+ " ?g fog:asObj_v3.0-obj ?obj \r\n"
+ "} ");
Query query = QueryFactory.create("""
PREFIX fog: <https://w3id.org/fog#>\r
\r
SELECT ?e ?wkt ?obj WHERE {\r
?e <https://w3id.org/omg#hasGeometry> ?g .\r
?g <https://www.opengis.net/ont/geosparql#asWKT> ?wkt .\r
?g fog:asObj_v3.0-obj ?obj \r
}\s""");
try (QueryExecution queryExecution = QueryExecutionFactory.create(query, m)) {
ResultSet rs = queryExecution.execSelect();
rs.forEachRemaining(qs -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public Model convert(String ifc_filename, ConversionProperties props) {
private static String unzip(String ifcZipFile) {
int BUFFER_SIZE = 32 * 1024; // 32KB
// JO 2024: performance
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(ifcZipFile),BUFFER_SIZE));){
try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(ifcZipFile),BUFFER_SIZE))){
byte[] buffer = new byte[1024];

ZipEntry zipEntry = zis.getNextEntry();
Expand All @@ -296,18 +296,14 @@ private static String unzip(String ifcZipFile) {
while ((len = zis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
fos.close();
}
zipEntry = zis.getNextEntry();
zis.close();
newFile.deleteOnExit();
return newFile.getAbsolutePath();
}

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {

e.printStackTrace();
}
return null;
Expand Down Expand Up @@ -375,7 +371,7 @@ public Model convert(String ifc_filename, String target_file, boolean hasBuildin

return convert(ifc_filename, target_file, hasBuildingElements, hasSeparateBuildingElementsModel,
hasBuildingProperties, hasSeparatePropertiesModel, hasGeolocation, hasGeometry, exportIfcOWL, hasUnits,
(exportIfcOWL) ? false : true, hasBoundingBoxWKT,false);
!exportIfcOWL, hasBoundingBoxWKT,false);
}

public Model convert(String ifc_filename, String target_file, boolean hasBuildingElements,
Expand All @@ -385,7 +381,7 @@ public Model convert(String ifc_filename, String target_file, boolean hasBuildin

return convert(ifc_filename, target_file, hasBuildingElements, hasSeparateBuildingElementsModel,
hasBuildingProperties, hasSeparatePropertiesModel, hasGeolocation, hasGeometry, exportIfcOWL, hasUnits,
(exportIfcOWL) ? false : true, hasBoundingBoxWKT,hasHierarchicalNaming);
!exportIfcOWL, hasBoundingBoxWKT,hasHierarchicalNaming);
}

public Model convert(String ifc_filename, String target_file, boolean hasBuildingElements,
Expand Down Expand Up @@ -541,31 +537,30 @@ public static void main(String[] args) {
inputFiles = FileUtils.listFiles(args[0]);
//outputFiles = null;

for (int i = 0; i < inputFiles.size(); ++i) {
final String inputFile = inputFiles.get(i);
String outputFile;
if (inputFile.endsWith(".ifc")) {
//TODO Check this
//if (outputFiles == null) {
outputFile = inputFile.substring(0, inputFile.length() - 4) + ".ttl";
//} else {
// outputFile = outputFiles.get(i);
//}

outputFile = outputFile.replaceAll(args[0], args[0] + "\\___out\\");
String copyFile = inputFile.replaceAll(args[0], args[0] + "\\___done\\");

// move file to output directory
System.out.println("--------- converting: " + inputFile);
new IFCtoLBDConverter(inputFile, "https://dot.ugent.be/IFCtoLBDset#", outputFile, 0, true, false,
true, false, false, false);

// move original file to output directory
File afile = new File(inputFile);
afile.renameTo(new File(copyFile));
System.out.println("--------- done ");
}
}
for (final String inputFile : inputFiles) {
String outputFile;
if (inputFile.endsWith(".ifc")) {
//TODO Check this
//if (outputFiles == null) {
outputFile = inputFile.substring(0, inputFile.length() - 4) + ".ttl";
//} else {
// outputFile = outputFiles.get(i);
//}

outputFile = outputFile.replaceAll(args[0], args[0] + "\\___out\\");
String copyFile = inputFile.replaceAll(args[0], args[0] + "\\___done\\");

// move file to output directory
System.out.println("--------- converting: " + inputFile);
new IFCtoLBDConverter(inputFile, "https://dot.ugent.be/IFCtoLBDset#", outputFile, 0, true, false,
true, false, false, false);

// move original file to output directory
File afile = new File(inputFile);
afile.renameTo(new File(copyFile));
System.out.println("--------- done ");
}
}
} else {
System.out.println("Usage:");
System.out.println("IFCtoLBDConverter ifc_filename base_uri targer_file ");
Expand All @@ -581,9 +576,9 @@ public void close()
if(this.lbd_general_output_model!=null)
lbd_general_output_model.close();
if(this.lbd_product_output_model!=null)
lbd_product_output_model.close();;
if(this.lbd_property_output_model!=null)
lbd_property_output_model.close();;
lbd_product_output_model.close();
if(this.lbd_property_output_model!=null)
lbd_property_output_model.close();
if(this.ifcowl_model!=null)
ifcowl_model.removeAll();
this.ifcowl_product_map.clear();
Expand Down
Loading

0 comments on commit e82e7d2

Please sign in to comment.