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

when image link is to a submap subdirectry sstructure to the file name is...

when image link is to a submap subdirectry sstructure to the file name is possible (but not requested)
parent a78f1362
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 {
/**
* Method that parse zip file and creates list of {@link OverviewImage images}
* from it.
*
*
* @param models
* map with models where the key is name of the file and value is model
* that was parsed from the file
......@@ -219,7 +219,7 @@ public class OverviewParser {
/**
* This method process data from {@link #COORDINATES_FILENAME} in zip archive.
* This method adds connections between images and between images and models.
*
*
* @param models
* map with models where the key is name of the file and value is model
* that was parsed from the file
......@@ -328,7 +328,7 @@ public class OverviewParser {
}
String filename = columns[filenameColumn];
String polygon = columns[polygonColumn];
String modelName = FilenameUtils.removeExtension(columns[targetFilenameColumn]);
String modelName = FilenameUtils.getBaseName(columns[targetFilenameColumn]);
String coord = columns[redirectionCoordinatesColumn];
String zoomLevel = columns[zoomLevelColumn];
String linkType = columns[targetTypeColumn];
......@@ -365,7 +365,7 @@ public class OverviewParser {
/**
* Creates a link from parameters and place it in appropriate
* {@link OverviewImage}.
*
*
* @param filename
* {@link OverviewImage#filename name of the image}
* @param polygon
......
......@@ -25,70 +25,105 @@ import lcsb.mapviewer.model.map.model.ModelData;
public class ProjectFactoryTest {
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testOverviewImageLink() throws Exception {
try {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ProjectFactory projectFactory = new ProjectFactory(converter);
ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.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(1, result.size());
OverviewImage img = result.get(0);
assertEquals("test.png", img.getFilename());
assertEquals((Integer) 639, img.getHeight());
assertEquals((Integer) 963, img.getWidth());
assertEquals(2, img.getLinks().size());
OverviewLink link = img.getLinks().get(0);
List<Point2D> polygon = link.getPolygonCoordinates();
assertEquals(4, polygon.size());
assertTrue(link instanceof OverviewModelLink);
OverviewModelLink mLink = (OverviewModelLink) link;
assertEquals((Integer) 10, mLink.getxCoord());
assertEquals((Integer) 10, mLink.getyCoord());
assertEquals((Integer) 3, mLink.getZoomLevel());
assertEquals(model, mLink.getLinkedModel());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testOverviewImageLink() throws Exception {
try {
ComplexZipConverter converter = new ComplexZipConverter(MockConverter.class);
ProjectFactory projectFactory = new ProjectFactory(converter);
ZipFile zipFile = new ZipFile("testFiles/complex_model_with_img.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(1, result.size());
OverviewImage img = result.get(0);
assertEquals("test.png", img.getFilename());
assertEquals((Integer) 639, img.getHeight());
assertEquals((Integer) 963, img.getWidth());
assertEquals(2, img.getLinks().size());
OverviewLink link = img.getLinks().get(0);
List<Point2D> polygon = link.getPolygonCoordinates();
assertEquals(4, polygon.size());
assertTrue(link instanceof OverviewModelLink);
OverviewModelLink mLink = (OverviewModelLink) link;
assertEquals((Integer) 10, mLink.getxCoord());
assertEquals((Integer) 10, mLink.getyCoord());
assertEquals((Integer) 3, mLink.getZoomLevel());
assertEquals(model, mLink.getLinkedModel());
} catch (Exception e) {
e.printStackTrace();
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