List of usage examples for org.apache.poi.ss.usermodel WorkbookFactory create
public static Workbook create(File file) throws IOException, EncryptedDocumentException
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testDatasourceParentComponent() throws Exception { InputStream input = getClass().getClassLoader() .getResourceAsStream("test-datasource-params-parentComponent.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/test-datasource-params-parentComponent.xlsx"); loader.load(book, graph, file);//from w w w . j a va2 s.c o m input.close(); URI shapeId = uri("https://schema.pearson.com/shapes/AccountShape"); ShapeManager s = loader.getShapeManager(); Shape shape = s.getShapeById(shapeId); List<DataSource> list = shape.getShapeDataSource(); assertEquals(2, list.size()); DataSource ds = list.get(1); assertEquals("http://schema.pearson.com/ns/system/mdm", ds.getIsPartOf().get(0).toString()); assertEquals("http://schema.pearson.com/ns/system/edw", ds.getIsPartOf().get(1).toString()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testGoogleOracleTable() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("omcs-oracle-table.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/omcs-oracle-table.xlsx"); loader.load(book, graph, file);/*w w w . j a v a 2s . c o m*/ input.close(); URI shapeId = uri("http://example.com/shapes/PersonShape"); ShapeManager s = loader.getShapeManager(); Shape shape = s.getShapeById(shapeId); assertTrue(shape != null); List<DataSource> list = shape.getShapeDataSource(); assertEquals(1, list.size()); DataSource ds = list.get(0); assertEquals("http://www.konig.io/ns/omcs/instances/test/databases/schema/tables/Person", ds.getId().stringValue()); assertTrue(ds.isA(Konig.OracleTable)); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testAssessmentEndeavor() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("assessment-endeavor.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/assessment-endeavor.xlsx"); loader.load(book, graph, file);/* www. j a v a 2 s . co m*/ input.close(); URI shapeId = uri("http://schema.pearson.com/shapes/AssessmentEndeavorShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); PropertyConstraint p = shape.getPropertyConstraint(AS.actor); assertTrue(p != null); assertTrue(p.getShape() == null); assertEquals(NodeKind.IRI, p.getNodeKind()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testAddressCountry() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("address-country.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/address-country.xlsx"); loader.load(book, graph, file);/*from ww w. j av a2 s .c o m*/ input.close(); URI shapeId = uri("http://example.com/shapes/PersonShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); List<PropertyConstraint> propertyList = shape.getProperty(); SequencePath sequence = null; for (PropertyConstraint p : propertyList) { PropertyPath path = p.getPath(); if (path instanceof SequencePath) { sequence = (SequencePath) path; } } assertTrue(sequence != null); assertEquals(2, sequence.size()); PropertyPath address = sequence.get(0); assertTrue(address instanceof PredicatePath); PredicatePath predicatePath = (PredicatePath) address; assertEquals(Schema.address, predicatePath.getPredicate()); PropertyPath country = sequence.get(1); assertTrue(country instanceof PredicatePath); predicatePath = (PredicatePath) country; assertEquals(Schema.addressCountry, predicatePath.getPredicate()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testSequencePath() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("sequence-path.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/sequence-path.xlsx"); loader.load(book, graph, file);/*from www .j a v a 2 s . co m*/ input.close(); URI shapeId = uri("http://example.com/shapes/PersonShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); SequencePath sequence = null; for (PropertyConstraint p : shape.getVariable()) { PropertyPath path = p.getPath(); if (path instanceof SequencePath) { if (sequence == null) { sequence = (SequencePath) path; } else { fail("Expected only one sequence path, but found more than one"); } } } if (sequence == null) { fail("SequencePath not found"); } assertEquals(2, sequence.size()); PropertyPath first = sequence.get(0); assertTrue(first instanceof PredicatePath); PredicatePath predicatePath = (PredicatePath) first; assertEquals(uri(VAR.NAMESPACE + "?x"), predicatePath.getPredicate()); PropertyPath second = sequence.get(1); assertTrue(second instanceof PredicatePath); predicatePath = (PredicatePath) second; assertEquals(Schema.givenName, predicatePath.getPredicate()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testIriReference() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("iri-reference.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/iri-reference.xlsx"); loader.load(book, graph, file);/* w w w. j a va 2 s .c o m*/ input.close(); URI shapeId = uri("http://example.com/shape/PersonShape"); Shape shape = loader.getShapeManager().getShapeById(shapeId); assertTrue(shape != null); assertEquals(shape.getNodeKind(), NodeKind.IRI); PropertyConstraint p = shape.getPropertyConstraint(Schema.memberOf); assertTrue(p != null); assertEquals(p.getNodeKind(), NodeKind.IRI); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testLabels() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("labels.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/labels.xlsx"); loader.load(book, graph, file);//from w ww.j ava 2 s. c o m input.close(); String arabicValue = "\u0627\u0644\u0627\u0633\u0645 \u0627\u0644\u0645\u0639\u0637\u0649"; assertLabel(graph, Schema.givenName, "Given Name", "en"); assertLabel(graph, Schema.givenName, "Pr\u00E9nom", "fr"); assertLabel(graph, Schema.givenName, arabicValue, "ar"); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testPubSub() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("pubsub.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/pubsub.xlsx"); loader.load(book, graph, file);//from www . j a v a 2 s .co m input.close(); URI topicId = uri("https://pubsub.googleapis.com/v1/projects/${gcpProjectId}/topics/vnd.example.person"); URI shapeId = uri("http://example.com/shapes/PersonShape"); Shape shape = loader.getShapeManager().getShapeById(shapeId); assertTrue(shape != null); DataSource topic = shape.getShapeDataSource().stream().filter(s -> s.isA(Konig.GooglePubSubTopic)) .findFirst().get(); assertEquals(topicId, topic.getId()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testSubproperty() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("subproperty.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/subproperty.xlsx"); loader.load(book, graph, file);/*from w w w. j a v a 2 s .c om*/ input.close(); assertTrue(graph.contains(Schema.taxID, RDFS.SUBPROPERTYOF, Schema.identifier)); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testDefaultShape() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("default-shape.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); graph.setNamespaceManager(nsManager); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/default-shape.xlsx"); loader.load(book, graph, file);/*from www . j a v a 2 s.c o m*/ input.close(); ShapeManager shapeManager = loader.getShapeManager(); URI shapeId = uri("http://example.com/shapes/PersonShape"); Shape shape = shapeManager.getShapeById(shapeId); assertTrue(shape != null); List<URI> appList = shape.getDefaultShapeFor(); assertTrue(appList != null); assertEquals(2, appList.size()); assertTrue(appList.contains(uri("http://example.com/applications/MyCatalog"))); assertTrue(appList.contains(uri("http://example.com/applications/MyShoppingCart"))); }