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

is number uses proper function check

parent 8c6d4271
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",!545Import from sbgn issue
......@@ -10,6 +10,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.sbgn.ArcClazz;
import org.sbgn.GlyphClazz;
......@@ -196,50 +197,45 @@ public class SbgnmlXmlExporter {
/**
* Creates new glyph element with all parameters from given alias.
*
* @param alias
* @param element
* alias with all parameters for the glyph
* @return newly created glyph
*/
private Glyph aliasToGlyph(Element alias) {
private Glyph aliasToGlyph(Element element) {
Glyph newGlyph = new Glyph();
boolean idIsANumber = true;
try {
Integer.parseInt(alias.getElementId().substring(0, 1));
} catch (NumberFormatException e) {
idIsANumber = false;
}
boolean idIsANumber = StringUtils.isNumeric(element.getElementId().substring(0, 1));
if (idIsANumber) {
newGlyph.setId(RandomStringUtils.randomAlphabetic(ID_RANDOM_STRING_LENGTH).concat(alias.getElementId()));
newGlyph.setId(RandomStringUtils.randomAlphabetic(ID_RANDOM_STRING_LENGTH).concat(element.getElementId()));
} else {
newGlyph.setId(alias.getElementId());
newGlyph.setId(element.getElementId());
}
newGlyph.setClazz(getGlyphClazzFromElement(alias).getClazz());
newGlyph.setLabel(getGlyphLabelFromAlias(alias));
newGlyph.setClazz(getGlyphClazzFromElement(element).getClazz());
newGlyph.setLabel(getGlyphLabelFromAlias(element));
Bbox bbox = new Bbox();
bbox.setX(alias.getX().floatValue());
bbox.setY(alias.getY().floatValue());
bbox.setW(alias.getWidth().floatValue());
bbox.setH(alias.getHeight().floatValue());
bbox.setX(element.getX().floatValue());
bbox.setY(element.getY().floatValue());
bbox.setW(element.getWidth().floatValue());
bbox.setH(element.getHeight().floatValue());
newGlyph.setBbox(bbox);
if (GlyphClazz.fromClazz(newGlyph.getClazz()).equals(GlyphClazz.MACROMOLECULE)
|| GlyphClazz.fromClazz(newGlyph.getClazz()).equals(GlyphClazz.MACROMOLECULE_MULTIMER)) {
Protein protein = (Protein) alias;
Protein protein = (Protein) element;
for (ModificationResidue mr : protein.getModificationResidues()) {
Glyph stateVariableGlyph = parseStateVariable(mr, newGlyph);
Glyph stateVariableGlyph = parseStateVariable(mr);
stateVariableGlyph.setId(newGlyph.getId().concat("-").concat(stateVariableGlyph.getId()));
newGlyph.getGlyph().add(stateVariableGlyph);
}
}
Glyph unitOfInformationGlyph = getUnitOfInformationGlyph(alias);
Glyph unitOfInformationGlyph = getUnitOfInformationGlyph(element);
if (unitOfInformationGlyph != null) {
newGlyph.getGlyph().add(unitOfInformationGlyph);
}
if (alias instanceof Complex) {
Complex complexAlias = (Complex) alias;
if (element instanceof Complex) {
Complex complexAlias = (Complex) element;
for (Species a : complexAlias.getElements()) {
Glyph childGlyph = aliasToGlyph(a);
newGlyph.getGlyph().add(childGlyph);
......@@ -424,11 +420,9 @@ public class SbgnmlXmlExporter {
*
* @param mr
* {@link ModificationResidue} to be parsed
* @param parentGlyph
* parent glyph for the state variable
* @return state variable glyph
*/
private Glyph parseStateVariable(ModificationResidue mr, Glyph parentGlyph) {
private Glyph parseStateVariable(ModificationResidue mr) {
Glyph glyph = new Glyph();
glyph.setId(mr.getIdModificationResidue());
glyph.setClazz(GlyphClazz.STATE_VARIABLE.getClazz());
......
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