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 testAggregateFunction() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("aggregate-function.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/aggregate-function.xlsx"); loader.load(book, graph, file);/*w ww . ja va2 s . c o m*/ input.close(); ShapeManager shapeManager = loader.getShapeManager(); URI shapeId = uri("http://example.com/shapes/AssessmentMetricsShape"); Shape shape = shapeManager.getShapeById(shapeId); assertTrue(shape != null); PropertyConstraint p = shape.getVariableByName("?x"); assertTrue(p != null); URI AssessmentResult = uri("http://example.com/ns/core/AssessmentResult"); assertEquals(AssessmentResult, p.getValueClass()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testDatasourceParams() throws Exception { GcpShapeConfig.init();//from w ww.java2s . c o m InputStream input = getClass().getClassLoader().getResourceAsStream("test-datasource-params.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.xlsx"); loader.load(book, graph, file); input.close(); URI shapeId = uri("http://example.com/shapes/ProductShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); List<DataSource> dsList = shape.getShapeDataSource().stream() .filter(ds -> ds.isA(Konig.GoogleBigQueryTable)).collect(Collectors.toList()); assertEquals(1, dsList.size()); DataSource ds = dsList.get(0); assertTrue(ds instanceof GoogleBigQueryTable); GoogleBigQueryTable table = (GoogleBigQueryTable) ds; String tableId = table.getTableReference().getTableId(); assertTrue(tableId != null); assertEquals("CustomProduct", tableId); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testIriTemplate() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("test-iri-template.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-iri-template.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/shapes/ProductShape"); Shape shape = loader.getShapeManager().getShapeById(shapeId); IriTemplate template = shape.getIriTemplate(); String expected = "@context {\n" + " \"schema\" : \"http://schema.org/\",\n" + " \"name\" : \"schema:name\"\n" + "}\n" + "\n" + "<http://example.com/product/{name}>"; assertTrue(template != null); assertEquals(expected, template.toString()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testDataSource() throws Exception { GcpShapeConfig.init();//from w w w . ja va 2 s .c o m InputStream input = getClass().getClassLoader().getResourceAsStream("issue-161.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/issue-161.xlsx"); loader.load(book, graph, file); input.close(); URI shapeId = uri("http://example.com/shapes/PersonLiteShape"); Shape shape = loader.getShapeManager().getShapeById(shapeId); assertTrue(shape != null); GoogleBigQueryTable table = shape.findDataSource(GoogleBigQueryTable.class); assertTrue(table != null); URI datasourceId = uri( "https://www.googleapis.com/bigquery/v2/projects/${gcpProjectId}/datasets/schema/tables/Person"); assertEquals(table.getId(), datasourceId); BigQueryTableReference tableRef = table.getTableReference(); assertTrue(tableRef != null); assertEquals(tableRef.getProjectId(), "${gcpProjectId}"); assertEquals(tableRef.getDatasetId(), "schema"); assertEquals(tableRef.getTableId(), "Person"); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testPlaceData() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("place-data.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); WorkbookLoader loader = new WorkbookLoader(nsManager); loader.setFailOnWarnings(false);//from w ww . j a v a 2s . com File file = new File("src/test/resources/place-data.xlsx"); loader.load(book, graph, file); URI placeId = uri("http://example.com/place/us"); Vertex place = graph.getVertex(placeId); assertTrue(place != null); Vertex address = place.getVertex(Schema.address); assertTrue(address != null); assertValue(address, Schema.addressCountry, "US"); placeId = uri("http://example.com/place/us/nj"); place = graph.getVertex(placeId); assertTrue(place != null); address = place.getVertex(Schema.address); assertTrue(address != null); assertValue(address, Schema.addressCountry, "US"); assertValue(address, Schema.addressRegion, "NJ"); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testEquivalentPath() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("analytics-model.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/analytics-model.xlsx"); loader.load(book, graph, file);/* ww w.j av a 2s.c o m*/ URI shapeId = uri("http://example.com/shapes/SalesByCityShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); assertTrue(shape != null); URI state = uri("http://example.com/ns/alias/state"); PropertyConstraint p = shape.getPropertyConstraint(state); String expected = "/<http://www.konig.io/ns/var/?x>/location[type State]"; Path path = p.getEquivalentPath(); assertEquals(expected, path.toSimpleString()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testStereotype() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("analytics-model.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/analytics-model.xlsx"); loader.load(book, graph, file);/*w ww . j av a 2s. co m*/ URI shapeId = uri("http://example.com/shapes/SalesByCityShape"); ShapeManager shapeManager = loader.getShapeManager(); Shape shape = shapeManager.getShapeById(shapeId); assertTrue(shape != null); PropertyConstraint totalCount = shape.getPropertyConstraint(Konig.totalCount); assertTrue(totalCount != null); assertEquals(Konig.measure, totalCount.getStereotype()); URI cityId = uri("http://example.com/ns/alias/city"); PropertyConstraint city = shape.getPropertyConstraint(cityId); assertTrue(city != null); assertEquals(Konig.dimension, city.getStereotype()); // RdfUtil.prettyPrintTurtle(nsManager, graph, new OutputStreamWriter(System.out)); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void test() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("person-model.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/person-model.xlsx"); loader.load(book, graph, file);//w ww . j a v a 2s . co m checkOntologySheet(graph); checkNamespaces(nsManager); checkClasses(graph); checkProperties(graph); checkIndividuals(graph); checkShapes(loader); checkPropertyConstraints(loader); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testAmazonRDSCluster() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("person-model-amazon-rds.xlsx"); Workbook book = WorkbookFactory.create(input); Graph graph = new MemoryGraph(); NamespaceManager nsManager = new MemoryNamespaceManager(); WorkbookLoader loader = new WorkbookLoader(nsManager); File file = new File("src/test/resources/person-model-amazon-rds.xlsx"); loader.load(book, graph, file);/*from ww w.j av a 2s . c o m*/ Vertex shape = graph.getVertex(uri("https://amazonaws.konig.io/rds/cluster/${environmentName}-test")); assertValue(shape, AWS.dbClusterId, "${environmentName}-test"); assertValue(shape, AWS.dbClusterName, "test"); assertValue(shape, AWS.engine, "aurora"); assertValue(shape, AWS.engineVersion, "5.6.10a"); assertValue(shape, AWS.instanceClass, "db.r4.large"); assertValue(shape, AWS.backupRetentionPeriod, "1"); assertValue(shape, AWS.databaseName, "pearson-edw"); assertValue(shape, AWS.dbSubnetGroupName, "default"); assertValue(shape, AWS.preferredBackupWindow, "04:22-04:52"); assertValue(shape, AWS.preferredMaintenanceWindow, "fri:06:44-fri:07:14"); assertValue(shape, AWS.replicationSourceIdentifier, "arn:aws:rds:us-west-2:123456789012:cluster:aurora-cluster1"); assertValue(shape, AWS.storageEncrypted, "0"); List<Value> list = graph.v(uri("https://amazonaws.konig.io/rds/cluster/${environmentName}-test")) .out(AWS.availabilityZone).toValueList(); assertEquals(3, list.size()); }
From source file:io.konig.spreadsheet.WorkbookLoaderTest.java
License:Apache License
@Ignore public void testAwsTable() throws Exception { InputStream input = getClass().getClassLoader().getResourceAsStream("awsAurora-transform.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/awsAurora-transform.xlsx"); loader.load(book, graph, file);//from ww w . ja v a 2s.c om input.close(); URI shapeId = uri("http://example.com/shapes/AuroraProductShape"); 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/aws/host/devHost/databases/edwcore/tables/AuroraProductShape", ds.getId().stringValue()); assertTrue(ds.isA(Konig.AwsAuroraTable)); }