-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
c3702d7
commit c6b2776
Showing
3 changed files
with
153 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,61 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
~ Copyright (c) 2023 SPARQL Anything Contributors @ http://github.com/sparql-anything | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.sparql-anything</groupId> | ||
<artifactId>sparql-anything-parent</artifactId> | ||
<version>${revision}</version> | ||
</parent> | ||
<properties> | ||
<revision>0.9.0-SNAPSHOT</revision> | ||
</properties> | ||
<artifactId>sparql-anything-slides</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.sparql-anything</groupId> | ||
<artifactId>sparql-anything-model</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.sparql-anything</groupId> | ||
<artifactId>sparql-anything-testutils</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> | ||
<dependency> | ||
<groupId>org.apache.poi</groupId> | ||
<artifactId>poi-ooxml</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
92 changes: 92 additions & 0 deletions
92
sparql-anything-slides/src/main/java/io/github/sparqlanything/slides/PptxTriplifier.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,92 @@ | ||
/* | ||
* Copyright (c) 2023 SPARQL Anything Contributors @ http://github.com/sparql-anything | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.github.sparqlanything.slides; | ||
|
||
import io.github.sparqlanything.model.*; | ||
import org.apache.poi.xslf.usermodel.XMLSlideShow; | ||
import org.apache.poi.xslf.usermodel.XSLFSlide; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
public class PptxTriplifier implements Triplifier { | ||
|
||
public final static String MERGE_PARAGRAPHS = "docs.merge-paragraphs"; | ||
public final static String TABLE_HEADERS = "docs.table-headers"; | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(PptxTriplifier.class); | ||
|
||
private static void addOptionalValue(FacadeXGraphBuilder builder, String dataSourceId, String containerId, String slotKey, String type, Object value){ | ||
if(value!=null){ | ||
String newContainer = containerId + "/" + | ||
builder.addValue(dataSourceId, containerId, slotKey, value); | ||
} | ||
} | ||
|
||
@Override | ||
public void triplify(Properties properties, FacadeXGraphBuilder builder) throws IOException, TriplifierHTTPException { | ||
URL url = Triplifier.getLocation(properties); | ||
if (url == null) | ||
return; | ||
String dataSourceId = ""; | ||
String namespace = PropertyUtils.getStringProperty(properties, IRIArgument.NAMESPACE); | ||
|
||
builder.addRoot(dataSourceId); | ||
|
||
InputStream is = url.openStream(); | ||
int slideNumber = 1; | ||
|
||
try (XMLSlideShow slides = new XMLSlideShow(is)) { | ||
|
||
builder.addType(dataSourceId, SPARQLAnythingConstants.ROOT_ID, "Presentation"); | ||
|
||
for(XSLFSlide slide : slides.getSlides()){ | ||
String slideId = dataSourceId + "_slide_" + slideNumber; | ||
builder.addContainer(dataSourceId, SPARQLAnythingConstants.ROOT_ID, 1, slideId); | ||
slideNumber ++; | ||
|
||
builder.addType(dataSourceId, slideId, "Slide"); | ||
addOptionalValue(builder, dataSourceId, slideId, "title", slide.getTitle() ); | ||
addOptionalValue(builder, dataSourceId, slideId, "name", slide.getSlideName() ); | ||
addOptionalValue(builder, dataSourceId, slideId, "number", slide.getSlideNumber() ); | ||
addOptionalValue(builder, dataSourceId, slideId, "number", slide.get ); | ||
|
||
|
||
} | ||
} | ||
|
||
|
||
} | ||
|
||
@Override | ||
public Set<String> getMimeTypes() { | ||
// return Sets.newHashSet("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Set<String> getExtensions() { | ||
// return Sets.newHashSet("docx"); | ||
return null; | ||
} | ||
|
||
} |
Binary file not shown.