Skip to content
Snippets Groups Projects
Commit 99659013 authored by David Hoksza's avatar David Hoksza Committed by Piotr Gawron
Browse files

non-tested alpha implementation

parent 131f5a36
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!418Formats conversion rest api
package lcsb.mapviewer.api.convert;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.xml.stream.XMLStreamException;
import org.apache.log4j.Logger;
import org.sbml.jsbml.SBMLException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.api.ObjectNotFoundException;
import lcsb.mapviewer.api.QueryException;
import lcsb.mapviewer.commands.CommandExecutionException;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.ConverterException;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException;
import lcsb.mapviewer.services.SecurityException;
@RestController
public class ConvertController extends BaseController {
@SuppressWarnings("unused")
private Logger logger = Logger.getLogger(ConvertController.class);
@Autowired
private ConvertRestImpl convertController;
@RequestMapping(value = "/convert/{fromFormat:celldesigner|sbml|sbgn}:{toFormat:celldesigner|sbml|sbgn}",
method = { RequestMethod.POST }, produces = {
MediaType.TEXT_PLAIN_VALUE })
public String convertInput(//
@PathVariable(value = "fromFormat") String fromFormat, //
@PathVariable(value = "toFormat") String toFormat, //
@RequestBody String body, //
@CookieValue(value = Configuration.AUTH_TOKEN) String token //
) throws SecurityException, IOException, QueryException, SBMLException,
InvalidInputDataExecption, InconsistentModelException, ConverterException, XMLStreamException {
return convertController.convert(token, fromFormat, toFormat, body);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -35,4 +35,6 @@
<bean id="ReferenceGenomeRestImpl" class="lcsb.mapviewer.api.genomics.ReferenceGenomeRestImpl"/>
<bean id="UserRestImpl" class="lcsb.mapviewer.api.users.UserRestImpl"/>
<bean id="ConvertRestImpl" class="lcsb.mapviewer.api.convert.ConvertRestImpl"/>
</beans>
\ No newline at end of file
......@@ -5,6 +5,7 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import lcsb.mapviewer.api.configuration.AllConfigurationTests;
import lcsb.mapviewer.api.convert.AllConvertTests;
import lcsb.mapviewer.api.files.AllFileTests;
import lcsb.mapviewer.api.genomics.AllGenomicsTests;
import lcsb.mapviewer.api.mesh.AllMeshTests;
......@@ -13,7 +14,8 @@ import lcsb.mapviewer.api.users.AllUserTests;
@RunWith(Suite.class)
@SuiteClasses({ AllConfigurationTests.class, //
AllFileTests.class, //
AllConvertTests.class, //
AllFileTests.class, //
AllGenomicsTests.class, //
AllMeshTests.class, //
AllProjectTests.class, //
......
package lcsb.mapviewer.api.convert;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ ConvertRestImplTest.class })
public class AllConvertTests {
}
package lcsb.mapviewer.api.convert;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.api.RestTestFunctions;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction;
import lcsb.mapviewer.model.map.species.GenericProtein;
public class ConvertRestImplTest extends RestTestFunctions {
@SuppressWarnings("unused")
private Logger logger = Logger.getLogger(ConvertRestImplTest.class);
@Autowired
public ConvertRestImpl convertRestImpl;
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testCelDesigner2Sbml() throws Exception {
try {
String result = convertRestImpl.convert(token, "celldesigner", "sbml", "content");
assertTrue(result.length() > 0);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
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