Skip to content
Snippets Groups Projects
Commit 81aa3dd8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '440-uploading-zip-file-fails-openlayers' into 'master'

Resolve "Uploading zip file fails (OpenLayers)"

Closes #440

See merge request !331
parents a78f1362 150895c6
No related branches found
No related tags found
1 merge request!331Resolve "Uploading zip file fails (OpenLayers)"
Pipeline #
...@@ -113,7 +113,7 @@ public class OverviewParser { ...@@ -113,7 +113,7 @@ public class OverviewParser {
/** /**
* Method that parse zip file and creates list of {@link OverviewImage images} * Method that parse zip file and creates list of {@link OverviewImage images}
* from it. * from it.
* *
* @param models * @param models
* map with models where the key is name of the file and value is model * map with models where the key is name of the file and value is model
* that was parsed from the file * that was parsed from the file
...@@ -219,7 +219,7 @@ public class OverviewParser { ...@@ -219,7 +219,7 @@ public class OverviewParser {
/** /**
* This method process data from {@link #COORDINATES_FILENAME} in zip archive. * This method process data from {@link #COORDINATES_FILENAME} in zip archive.
* This method adds connections between images and between images and models. * This method adds connections between images and between images and models.
* *
* @param models * @param models
* map with models where the key is name of the file and value is model * map with models where the key is name of the file and value is model
* that was parsed from the file * that was parsed from the file
...@@ -328,7 +328,7 @@ public class OverviewParser { ...@@ -328,7 +328,7 @@ public class OverviewParser {
} }
String filename = columns[filenameColumn]; String filename = columns[filenameColumn];
String polygon = columns[polygonColumn]; String polygon = columns[polygonColumn];
String modelName = FilenameUtils.removeExtension(columns[targetFilenameColumn]); String modelName = FilenameUtils.getBaseName(columns[targetFilenameColumn]);
String coord = columns[redirectionCoordinatesColumn]; String coord = columns[redirectionCoordinatesColumn];
String zoomLevel = columns[zoomLevelColumn]; String zoomLevel = columns[zoomLevelColumn];
String linkType = columns[targetTypeColumn]; String linkType = columns[targetTypeColumn];
...@@ -365,7 +365,7 @@ public class OverviewParser { ...@@ -365,7 +365,7 @@ public class OverviewParser {
/** /**
* Creates a link from parameters and place it in appropriate * Creates a link from parameters and place it in appropriate
* {@link OverviewImage}. * {@link OverviewImage}.
* *
* @param filename * @param filename
* {@link OverviewImage#filename name of the image} * {@link OverviewImage#filename name of the image}
* @param polygon * @param polygon
......
...@@ -25,70 +25,105 @@ import lcsb.mapviewer.model.map.model.ModelData; ...@@ -25,70 +25,105 @@ import lcsb.mapviewer.model.map.model.ModelData;
public class ProjectFactoryTest { public class ProjectFactoryTest {
@AfterClass @AfterClass
public static void tearDownAfterClass() throws Exception { public static void tearDownAfterClass() throws Exception {
} }
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
} }
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
} }
@Test @Test
public void testOverviewImageLink() throws Exception { public void testOverviewImageLink() throws Exception {
try { try {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class); ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ProjectFactory projectFactory = new ProjectFactory(converter); ProjectFactory projectFactory = new ProjectFactory(converter);
ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.zip"); ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.zip");
ComplexZipConverterParams params = new ComplexZipConverterParams(); ComplexZipConverterParams params = new ComplexZipConverterParams();
params.zipFile(zipFile); params.zipFile(zipFile);
ZipEntryFileFactory factory = new ZipEntryFileFactory(); ZipEntryFileFactory factory = new ZipEntryFileFactory();
Enumeration<? extends ZipEntry> entries = zipFile.entries(); Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement(); ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) { if (!entry.isDirectory()) {
params.entry(factory.createZipEntryFile(entry, zipFile)); params.entry(factory.createZipEntryFile(entry, zipFile));
} }
} }
Project project = projectFactory.create(params); Project project = projectFactory.create(params);
assertNotNull(project); assertNotNull(project);
ModelData model = project.getModels().iterator().next(); ModelData model = project.getModels().iterator().next();
assertEquals("main", model.getName()); assertEquals("main", model.getName());
List<OverviewImage> result = project.getOverviewImages(); List<OverviewImage> result = project.getOverviewImages();
assertNotNull(result); assertNotNull(result);
assertEquals(1, result.size()); assertEquals(1, result.size());
OverviewImage img = result.get(0); OverviewImage img = result.get(0);
assertEquals("test.png", img.getFilename()); assertEquals("test.png", img.getFilename());
assertEquals((Integer) 639, img.getHeight()); assertEquals((Integer) 639, img.getHeight());
assertEquals((Integer) 963, img.getWidth()); assertEquals((Integer) 963, img.getWidth());
assertEquals(2, img.getLinks().size()); assertEquals(2, img.getLinks().size());
OverviewLink link = img.getLinks().get(0); OverviewLink link = img.getLinks().get(0);
List<Point2D> polygon = link.getPolygonCoordinates(); List<Point2D> polygon = link.getPolygonCoordinates();
assertEquals(4, polygon.size()); assertEquals(4, polygon.size());
assertTrue(link instanceof OverviewModelLink); assertTrue(link instanceof OverviewModelLink);
OverviewModelLink mLink = (OverviewModelLink) link; OverviewModelLink mLink = (OverviewModelLink) link;
assertEquals((Integer) 10, mLink.getxCoord()); assertEquals((Integer) 10, mLink.getxCoord());
assertEquals((Integer) 10, mLink.getyCoord()); assertEquals((Integer) 10, mLink.getyCoord());
assertEquals((Integer) 3, mLink.getZoomLevel()); assertEquals((Integer) 3, mLink.getZoomLevel());
assertEquals(model, mLink.getLinkedModel()); assertEquals(model, mLink.getLinkedModel());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} }
} }
@Test
public void testOverviewImageLinkToSubmapPath() throws Exception {
try {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ProjectFactory projectFactory = new ProjectFactory(converter);
ZipFile zipFile = new ZipFile("testFiles/complex_model_with_images_path.zip");
ComplexZipConverterParams params = new ComplexZipConverterParams();
params.zipFile(zipFile);
ZipEntryFileFactory factory = new ZipEntryFileFactory();
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory()) {
params.entry(factory.createZipEntryFile(entry, zipFile));
}
}
Project project = projectFactory.create(params);
assertNotNull(project);
ModelData model = project.getModels().iterator().next();
assertEquals("main", model.getName());
List<OverviewImage> result = project.getOverviewImages();
assertNotNull(result);
assertEquals(2, result.size());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
} }
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment