-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
580db84
commit bd9d944
Showing
8 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eurocris</groupId> | ||
<artifactId>cerif2-owl-tools</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>Tools to create an OWL representation of the refactored CERIF</name> | ||
<organization> | ||
<name>euroCRIS</name> | ||
<url>https://ror.org/04340dw19</url> | ||
</organization> | ||
|
||
<properties> | ||
<fully.qualified.main.class.name>org.eurocris.cerif2.owl.Tools</fully.qualified.main.class.name> | ||
<maven.compiler.version>17</maven.compiler.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.sourceforge.owlapi</groupId> | ||
<artifactId>owlapi-distribution</artifactId> | ||
<version>5.5.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vladsch.flexmark</groupId> | ||
<artifactId>flexmark-all</artifactId> | ||
<version>0.64.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.4.11</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>${fully.qualified.main.class.name}</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
tools/owl/src/main/java/org/eurocris/cerif2/owl/Model.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.eurocris.cerif2.owl; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Model { | ||
|
||
protected final Logger log = LoggerFactory.getLogger( getClass().getName() ); | ||
|
||
public void readInDatatypeFile( final StructuredFile file ) { | ||
log.info( "Parsing {1} as a datatype", file ); | ||
} | ||
|
||
public void readInEntityFile( final StructuredFile file ) { | ||
log.info( "Parsing {1} as an entity", file ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.eurocris.cerif2.owl; | ||
|
||
public class Section { | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
tools/owl/src/main/java/org/eurocris/cerif2/owl/StructuredFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.eurocris.cerif2.owl; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
public class StructuredFile implements Iterable<Section> { | ||
|
||
private final Path path; | ||
|
||
private final String title; | ||
|
||
private final Map<String, Section> sectionsMap = new HashMap<>();; | ||
|
||
public StructuredFile( final Path path ) throws IOException { | ||
this.path = path; | ||
final Iterator<String> i = Files.lines( path ).iterator(); | ||
if (! i.hasNext() ) throw new IllegalArgumentException( "Empty file" ); | ||
final String line1 = i.next(); | ||
if (! line1.startsWith( "# " ) ) throw new IllegalArgumentException( "First line does not start with # and a space" ); | ||
this.title = line1.substring( 2 ); | ||
if (! i.hasNext() ) throw new IllegalArgumentException( "File contained just one line" ); | ||
final String line2 = i.next(); | ||
if (! line2.isEmpty() ) throw new IllegalArgumentException( "The second line is not empty" ); | ||
readInSections( i, sectionsMap ); | ||
} | ||
|
||
private static void readInSections( final Iterator<String> i, final Map<String, Section> sectionsMap2 ) { | ||
// TODO | ||
} | ||
|
||
public Path getPath() { | ||
return path; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
@Override | ||
public Iterator<Section> iterator() { | ||
return sectionsMap.values().iterator(); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
tools/owl/src/main/java/org/eurocris/cerif2/owl/Tools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.eurocris.cerif2.owl; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.DirectoryStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Tools { | ||
|
||
protected final static Logger log = LoggerFactory.getLogger( Tools.class.getName() ); | ||
|
||
public Tools() { | ||
} | ||
|
||
public static void main( final String[] args ) { | ||
final Tools tools = new Tools(); | ||
try { | ||
final Model model = tools.readIn( args ); | ||
} catch ( final IOException e ) { | ||
log.error( "When processing", e ); | ||
} | ||
} | ||
|
||
private Model readIn( final String[] dirs ) throws IOException { | ||
final Model model = new Model(); | ||
for ( final String dir : dirs ) { | ||
final File moduleBaseDir = new File( dir ); | ||
if ( moduleBaseDir.isDirectory() ) { | ||
try ( final DirectoryStream<Path> datatypes = Files.newDirectoryStream( moduleBaseDir.toPath().resolve( "datatypes" ), "*.md" ) ) { | ||
for ( final Path datatypeFilePath : datatypes ) { | ||
model.readInDatatypeFile( new StructuredFile( datatypeFilePath ) ); | ||
} | ||
} | ||
try ( final DirectoryStream<Path> entities = Files.newDirectoryStream( moduleBaseDir.toPath().resolve( "entities" ), "*.md" ) ) { | ||
for ( final Path entityFilePath : entities ) { | ||
model.readInEntityFile( new StructuredFile( entityFilePath ) ); | ||
} | ||
} | ||
} else { | ||
throw new IllegalArgumentException( dir + " does not resolve to a directory" ); | ||
} | ||
} | ||
log.info( "Model: {1}", model ); | ||
return model; | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" ?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder name="enc" class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> | ||
<pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern> | ||
<outputPatternAsHeader>true</outputPatternAsHeader> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
|
||
<logger name="org.eurocris" level="debug" /> | ||
|
||
</configuration> |