Commit 255488e1 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'performance-issue' into 'devel_16.0.x'

Performance issue

See merge request !1412
parents 749e4847 3602bb57
Pipeline #51133 passed with stage
in 14 minutes
......@@ -18,6 +18,7 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
......@@ -37,8 +38,8 @@ public class SbmlValidationTests extends CellDesignerTestFunctions {
Model model;
String filename;
public SbmlValidationTests(String filename, Model model) {
this.filename= filename;
public SbmlValidationTests(final String filename, final Model model) {
this.filename = filename;
this.model = model;
}
......@@ -66,15 +67,16 @@ public class SbmlValidationTests extends CellDesignerTestFunctions {
return new Object[] { "empty-protein-name", model };
}
private static Object[] getTestSetFromFile(String string) throws Exception {
private static Object[] getTestSetFromFile(final String string) throws Exception {
return new Object[] { string, getModelForFile(string) };
}
@Test
@Ignore("sbml validatior is down")
public void testIsValidSbml() throws Exception {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xml = parser.model2String(model);
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost uploadFile = new HttpPost("http://sbml.org/validator/");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
......
......@@ -6,6 +6,7 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
......@@ -24,7 +25,7 @@ public class GeneratedSbmlValidationTests extends SbmlTestFunctions {
Model model;
public GeneratedSbmlValidationTests(Model model, String name) {
public GeneratedSbmlValidationTests(final Model model, final String name) {
this.model = model;
}
......@@ -44,7 +45,7 @@ public class GeneratedSbmlValidationTests extends SbmlTestFunctions {
return model;
}
private static Object[] createRow(Model model) {
private static Object[] createRow(final Model model) {
new ZIndexPopulator().populateZIndex(model);
return new Object[] { model, model.getName() };
}
......@@ -64,6 +65,7 @@ public class GeneratedSbmlValidationTests extends SbmlTestFunctions {
}
@Test
@Ignore("sbml validatior is down")
public void testIsValidSbml() throws Exception {
SbmlParser parser = new SbmlParser();
String xml = parser.model2String(model);
......
......@@ -7,6 +7,7 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
......@@ -21,7 +22,7 @@ public class SbmlValidationTests extends SbmlTestFunctions {
String filename;
public SbmlValidationTests(String filename) {
public SbmlValidationTests(final String filename) {
this.filename = filename;
}
......@@ -36,6 +37,7 @@ public class SbmlValidationTests extends SbmlTestFunctions {
}
@Test
@Ignore("sbml validatior is down")
public void testIsValidSbml() throws Exception {
SbmlParser parser = new SbmlParser();
Model model = parser.createModel(new ConverterParams().filename(filename));
......
......@@ -101,7 +101,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Element.class.getSimpleName() + " element left join element.miriamData element_miriam"
+ " where element.model in :maps and entry.dataOverlay.id = :overlayId "
+ " and (lower(element.name) = lower(entry.name) or entry.name ='') "
+ " and (%ELEMENT_NAME_PART%) "
+ " and (lower(element.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = element_miriam.dataType and lower(entry_miriam.resource) = lower(element_miriam.resource)) ) "
+ " and (compartment is null or"
......@@ -113,15 +113,24 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
}
queryString += " group by entry, element";
org.hibernate.query.Query<?> query = getSession()
.createQuery(queryString)
org.hibernate.query.Query<?> query1 = getSession()
.createQuery(queryString.replace("%ELEMENT_NAME_PART%", "lower(element.name) = lower(entry.name) and entry.name <>''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (elementIdentifiers.size() > 0) {
query.setParameter("elementId", elementIdentifiers);
query1.setParameter("elementId", elementIdentifiers);
}
List<?> list = query.list();
org.hibernate.query.Query<?> query2 = getSession()
.createQuery(queryString.replace("%ELEMENT_NAME_PART%", "entry.name =''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (elementIdentifiers.size() > 0) {
query2.setParameter("elementId", elementIdentifiers);
}
List<Object> list = new ArrayList<>(query1.list());
list.addAll(query2.list());
return list;
}
......@@ -161,7 +170,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Reaction.class.getSimpleName() + " reaction left join reaction.miriamData reaction_miriam"
+ " where reaction.model in :maps and entry.dataOverlay.id = :overlayId "
+ " and (lower(reaction.name) = lower(entry.name) or entry.name ='') "
+ " and (%REACTION_NAME_PART%) "
+ " and (lower(reaction.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = reaction_miriam.dataType and lower(entry_miriam.resource) = lower(reaction_miriam.resource)) ) "
+ " and (lower(reaction.idReaction) = lower(entry.elementId) or entry.elementId='' or entry.elementId is null) ";
......@@ -171,16 +180,26 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
queryString += " group by entry, reaction";
org.hibernate.query.Query<?> query = getSession()
.createQuery(queryString)
org.hibernate.query.Query<?> query1 = getSession()
.createQuery(queryString.replace("%REACTION_NAME_PART%", "lower(reaction.name) = lower(entry.name) and entry.name <>''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (reactionIdentifiers.size() > 0) {
query1.setParameter("reactionId", reactionIdentifiers);
}
org.hibernate.query.Query<?> query2 = getSession()
.createQuery(queryString.replace("%REACTION_NAME_PART%", "entry.name =''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (reactionIdentifiers.size() > 0) {
query.setParameter("reactionId", reactionIdentifiers);
query2.setParameter("reactionId", reactionIdentifiers);
}
List<?> list = query.list();
List<Object> list = new ArrayList<>(query1.list());
list.addAll(query2.list());
return list;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment