Skip to content

Commit

Permalink
#429 Initial investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Nov 27, 2023
1 parent c3702d7 commit c6b2776
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 0 deletions.
61 changes: 61 additions & 0 deletions sparql-anything-slides/pom.xml
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>
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.

0 comments on commit c6b2776

Please sign in to comment.