Commit 6b8e255a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

variable name restricted

parent f57e146b
......@@ -152,8 +152,8 @@ public class PubmedParser extends CachableInterface implements IExternalService
// Document citationDoc = dBuilder.parse(citationStream);
mainDoc.getDocumentElement().normalize();
// citationDoc.getDocumentElement().normalize();
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
NodeList nodeList = null;
// Hit Count
nodeList = (NodeList) xpath.compile("/responseWrapper/resultList/result/citedByCount").evaluate(mainDoc,
......@@ -324,8 +324,8 @@ public class PubmedParser extends CachableInterface implements IExternalService
Document mainDoc = XmlParser.getXmlDocumentFromString(content);
mainDoc.getDocumentElement().normalize();
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
NodeList nodeList = (NodeList) xpath.compile("/responseWrapper/version").evaluate(mainDoc,
XPathConstants.NODESET);
if (nodeList.getLength() > 0) {
......
......@@ -63,6 +63,8 @@ public abstract class AnnotationTestFunctions extends AbstractTransactionalJUnit
private Logger logger = LogManager.getLogger();
private static int BLOCK_SIZE = 65536;
private static Map<String, Model> models = new HashMap<String, Model>();
@Rule
......@@ -228,7 +230,6 @@ public abstract class AnnotationTestFunctions extends AbstractTransactionalJUnit
}
protected boolean equalFiles(String fileA, String fileB) throws IOException {
int BLOCK_SIZE = 65536;
FileInputStream inputStreamA = new FileInputStream(fileA);
FileInputStream inputStreamB = new FileInputStream(fileB);
// vary BLOCK_SIZE to suit yourself.
......
......@@ -20,4 +20,8 @@
<suppress checks="MemberName"
files="lcsb.mapviewer.wikipathway.model.Edge.java"
lines="69"/>
<suppress checks="LocalVariableName"
files="lcsb.mapviewer.converter.graphics.placefinder.PlaceFinder.java"/>
</suppressions>
......@@ -177,7 +177,7 @@
<message key="name.invalidPattern"
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
</module>
<!-- <module name="CatchParameterName">
<module name="CatchParameterName">
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
<message key="name.invalidPattern"
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
......@@ -187,7 +187,7 @@
<message key="name.invalidPattern"
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="ClassTypeParameterName">
<!-- <module name="ClassTypeParameterName">
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
<message key="name.invalidPattern"
value="Class type name ''{0}'' must match pattern ''{1}''."/>
......
......@@ -196,12 +196,12 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> {
} else if (complex.getComplex() == null) {
ModelData modelData = complex.getModelData();
if (modelData != null) {
for (Compartment cAlias : modelData.getModel().getCompartments()) {
if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(complex)) {
for (Compartment compartment : modelData.getModel().getCompartments()) {
if (!(compartment instanceof PathwayCompartment) && compartment.cross(complex)) {
if (ca == null) {
ca = cAlias;
} else if (ca.getSize() > cAlias.getSize()) {
ca = cAlias;
ca = compartment;
} else if (ca.getSize() > compartment.getSize()) {
ca = compartment;
}
}
}
......
......@@ -184,12 +184,12 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
} else if (species.getComplex() == null) {
ModelData model = species.getModelData();
if (model != null) {
for (Compartment cAlias : model.getModel().getCompartments()) {
if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(species)) {
for (Compartment compartment : model.getModel().getCompartments()) {
if (!(compartment instanceof PathwayCompartment) && compartment.cross(species)) {
if (ca == null) {
ca = cAlias;
} else if (ca.getSize() > cAlias.getSize()) {
ca = cAlias;
ca = compartment;
} else if (ca.getSize() > compartment.getSize()) {
ca = compartment;
}
}
}
......
......@@ -722,16 +722,15 @@ public class RestAnnotationParser {
}
private void setZIndex(Drawable element, String annotationString) {
String zIndex = getParamByPrefix(annotationString,
NoteField.Z_INDEX.getCommonName() + ":");
if (zIndex != null) {
String stringValue = getParamByPrefix(annotationString, NoteField.Z_INDEX.getCommonName() + ":");
if (stringValue != null) {
try {
Integer z = Integer.valueOf(zIndex);
Integer z = Integer.valueOf(stringValue);
if (element.getZ() == null) {
element.setZ(z);
} else if (!element.getZ().equals(z)) {
logger.warn(elementUtils.getElementTag(element) + " New " + NoteField.Z_INDEX.getCommonName()
+ " different than default [" + zIndex + "][" + element.getZ() + "]. Ignoring.");
+ " different than default [" + stringValue + "][" + element.getZ() + "]. Ignoring.");
}
} catch (NumberFormatException e) {
logger.warn("Invalid e index", e);
......
......@@ -479,8 +479,8 @@ public class ReactionFromXml {
"Problem with parsing lines. Unknown reaction: " + type + "; " + result.getClass().getName(), result);
}
for (AbstractNode rNode : result.getNodes()) {
applyStylingToLine(line, rNode.getLine());
for (AbstractNode reactionNode : result.getNodes()) {
applyStylingToLine(line, reactionNode.getLine());
}
applyStylingToLine(line, result.getLine());
......@@ -818,10 +818,10 @@ public class ReactionFromXml {
toExclude = new HashSet<>();
toInclude = new HashSet<>();
for (NodeOperator nOperator : result.getOperators()) {
toExclude.addAll(nOperator.getOutputs());
if (nOperator.isProductOperator()) {
toInclude.add(nOperator);
for (NodeOperator nodeOperator : result.getOperators()) {
toExclude.addAll(nodeOperator.getOutputs());
if (nodeOperator.isProductOperator()) {
toInclude.add(nodeOperator);
}
}
......@@ -1681,8 +1681,8 @@ public class ReactionFromXml {
reaction.addModifier(mod);
}
} else {
ModifierType mType = modifierTypeUtils.getModifierTypeForStringType(type);
if (mType == null) {
ModifierType modifierType = modifierTypeUtils.getModifierTypeForStringType(type);
if (modifierType == null) {
String errorInfo = "[" + reaction.getClass().getSimpleName() + "\t" + reaction.getIdReaction()
+ "]\tUnknown modifier type: " + type;
if (ReactionLineData.getByCellDesignerString(type) != null) {
......@@ -1691,7 +1691,7 @@ public class ReactionFromXml {
throw new UnknownModifierClassException(errorInfo, type, reaction.getIdReaction());
}
for (Modifier modifier : reaction.getModifiers()) {
if (modifier.getElement() == aliasList.get(0) && modifier.getClass() == mType.getClazz()) {
if (modifier.getElement() == aliasList.get(0) && modifier.getClass() == modifierType.getClazz()) {
result = modifier;
}
}
......
......@@ -264,12 +264,12 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
} else if (species.getComplex() == null) {
ModelData modelData = species.getModelData();
if (modelData != null) {
for (Compartment cAlias : modelData.getModel().getCompartments()) {
if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(species)) {
for (Compartment compartment : modelData.getModel().getCompartments()) {
if (!(compartment instanceof PathwayCompartment) && compartment.cross(species)) {
if (comp == null) {
comp = cAlias;
} else if (comp.getSize() > cAlias.getSize()) {
comp = cAlias;
comp = compartment;
} else if (comp.getSize() > compartment.getSize()) {
comp = compartment;
}
}
}
......@@ -609,12 +609,12 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
modification.setIdModificationResidue(XmlParser.getNodeAttr("residue", rootNode));
String state = XmlParser.getNodeAttr("state", rootNode);
if (state != null) {
ModificationState mState = ModificationState.getByName(state);
if (mState == null) {
ModificationState modificationState = ModificationState.getByName(state);
if (modificationState == null) {
throw new InvalidXmlSchemaException("[" + modification.getClass().getSimpleName() + "\t"
+ modification.getIdModificationResidue() + "] Unknown modification state: " + state);
}
modification.setState(mState);
modification.setState(modificationState);
}
modification.setName(XmlParser.getNodeAttr("name", rootNode));
modification.setSize(XmlParser.getNodeAttr("size", rootNode));
......
......@@ -62,7 +62,11 @@ import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.SimpleMolecule;
public abstract class CellDesignerTestFunctions {
private static int BLOCK_SIZE = 65536;
protected static double EPSILON = Configuration.EPSILON;
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
private Logger logger = LogManager.getLogger();
......@@ -190,7 +194,6 @@ public abstract class CellDesignerTestFunctions {
}
protected boolean equalFiles(String fileA, String fileB) throws IOException {
int BLOCK_SIZE = 65536;
FileInputStream inputStreamA = new FileInputStream(fileA);
FileInputStream inputStreamB = new FileInputStream(fileB);
// vary BLOCK_SIZE to suit yourself.
......
......@@ -38,8 +38,8 @@ public class AntisenseRnaTest extends CellDesignerTestFunctions {
public void testConstructor1() {
CellDesignerAntisenseRna original = new CellDesignerAntisenseRna();
original.addRegion(new CellDesignerModificationResidue());
CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna(original);
assertNotNull(aRna);
CellDesignerAntisenseRna antisenseRna = new CellDesignerAntisenseRna(original);
assertNotNull(antisenseRna);
}
@Test
......@@ -98,19 +98,19 @@ public class AntisenseRnaTest extends CellDesignerTestFunctions {
@Test
public void testGetters() {
CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna(new CellDesignerSpecies<AntisenseRna>());
CellDesignerAntisenseRna antisenseRna = new CellDesignerAntisenseRna(new CellDesignerSpecies<AntisenseRna>());
List<CellDesignerModificationResidue> regions = new ArrayList<>();
aRna.setRegions(regions);
antisenseRna.setRegions(regions);
assertEquals(regions, aRna.getRegions());
assertEquals(regions, antisenseRna.getRegions());
}
@Test
public void testCopy() {
CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna().copy();
assertNotNull(aRna);
CellDesignerAntisenseRna antisenseRna = new CellDesignerAntisenseRna().copy();
assertNotNull(antisenseRna);
}
@Test(expected = NotImplementedException.class)
......
......@@ -410,44 +410,44 @@ public class SbgnmlXmlParser {
}
// If the arc is not connecting a submap or a tag, check it's points
if (!connectsTagOrSubmap) {
Start aStart = a.getStart();
if (aStart.getX() < minX) {
minX = aStart.getX();
Start start = a.getStart();
if (start.getX() < minX) {
minX = start.getX();
}
if (aStart.getX() > maxX) {
maxX = aStart.getX();
if (start.getX() > maxX) {
maxX = start.getX();
}
if (aStart.getY() < minY) {
minY = aStart.getY();
if (start.getY() < minY) {
minY = start.getY();
}
if (aStart.getY() > maxY) {
maxY = aStart.getY();
if (start.getY() > maxY) {
maxY = start.getY();
}
End aEnd = a.getEnd();
if (aEnd.getX() < minX) {
minX = aEnd.getX();
End end = a.getEnd();
if (end.getX() < minX) {
minX = end.getX();
}
if (aEnd.getX() > maxX) {
maxX = aEnd.getX();
if (end.getX() > maxX) {
maxX = end.getX();
}
if (aEnd.getY() < minY) {
minY = aEnd.getY();
if (end.getY() < minY) {
minY = end.getY();
}
if (aEnd.getY() > maxY) {
maxY = aEnd.getY();
if (end.getY() > maxY) {
maxY = end.getY();
}
for (Next aNext : a.getNext()) {
if (aNext.getX() < minX) {
minX = aNext.getX();
for (Next next : a.getNext()) {
if (next.getX() < minX) {
minX = next.getX();
}
if (aNext.getX() > maxX) {
maxX = aNext.getX();
if (next.getX() > maxX) {
maxX = next.getX();
}
if (aNext.getY() < minY) {
minY = aNext.getY();
if (next.getY() < minY) {
minY = next.getY();
}
if (aNext.getY() > maxY) {
maxY = aNext.getY();
if (next.getY() > maxY) {
maxY = next.getY();
}
}
}
......
......@@ -84,12 +84,12 @@ public class SbmlTestFunctions {
return result;
}
static int zIndex = 1;
static int z = 1;
protected static void assignCoordinates(double x, double y, double width, double height, Element protein) {
protein.setX(x);
protein.setY(y);
protein.setZ(zIndex++);
protein.setZ(z++);
protein.setWidth(width);
protein.setHeight(height);
protein.setNameX(x);
......
......@@ -97,10 +97,10 @@ public class ComplexZipConverterTest extends ConverterTestFunctions {
assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType());
assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel());
Element s1_al1 = s1Model.getElementByElementId("sa1");
assertNotNull(s1_al1.getSubmodel());
assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType());
assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel());
Element submap1Element1 = s1Model.getElementByElementId("sa1");
assertNotNull(submap1Element1.getSubmodel());
assertEquals(SubmodelType.DOWNSTREAM_TARGETS, submap1Element1.getSubmodel().getType());
assertEquals(s3Model, submap1Element1.getSubmodel().getSubmodel().getModel());
}
@Test
......@@ -150,10 +150,10 @@ public class ComplexZipConverterTest extends ConverterTestFunctions {
assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType());
assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel());
Element s1_al1 = s1Model.getElementByElementId("sa1");
assertNotNull(s1_al1.getSubmodel());
assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType());
assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel());
Element submodel1Element1 = s1Model.getElementByElementId("sa1");
assertNotNull(submodel1Element1.getSubmodel());
assertEquals(SubmodelType.DOWNSTREAM_TARGETS, submodel1Element1.getSubmodel().getType());
assertEquals(s3Model, submodel1Element1.getSubmodel().getSubmodel().getModel());
}
@Test(expected = InvalidArgumentException.class)
......
......@@ -44,6 +44,9 @@ import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
public abstract class ConverterTestFunctions {
private static int BLOCK_SIZE = 65536;
protected static double EPSILON = Configuration.EPSILON;
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
......@@ -167,7 +170,6 @@ public abstract class ConverterTestFunctions {
}
protected boolean equalFiles(String fileA, String fileB) throws IOException {
int BLOCK_SIZE = 65536;
FileInputStream inputStreamA = new FileInputStream(fileA);
FileInputStream inputStreamB = new FileInputStream(fileB);
// vary BLOCK_SIZE to suit yourself.
......
......@@ -67,12 +67,12 @@ public class OverviewParserTest extends ConverterTestFunctions {
assertTrue(link instanceof OverviewModelLink);
OverviewModelLink mLink = (OverviewModelLink) link;
OverviewModelLink modelLink = (OverviewModelLink) link;
Model mainModel = models.iterator().next();
assertEquals(mainModel.getModelData(), mLink.getLinkedModel());
assertEquals((Integer) 10, mLink.getxCoord());
assertEquals((Integer) 10, mLink.getyCoord());
assertEquals((Integer) 3, mLink.getZoomLevel());
assertEquals(mainModel.getModelData(), modelLink.getLinkedModel());
assertEquals((Integer) 10, modelLink.getxCoord());
assertEquals((Integer) 10, modelLink.getyCoord());
assertEquals((Integer) 3, modelLink.getZoomLevel());
}
@Test
......@@ -100,12 +100,12 @@ public class OverviewParserTest extends ConverterTestFunctions {
assertTrue(link instanceof OverviewModelLink);
OverviewModelLink mLink = (OverviewModelLink) link;
OverviewModelLink modelLink = (OverviewModelLink) link;
Model mainModel = models.iterator().next();
assertEquals(mainModel.getModelData(), mLink.getLinkedModel());
assertEquals((Integer) 10, mLink.getxCoord());
assertEquals((Integer) 10, mLink.getyCoord());
assertEquals((Integer) 3, mLink.getZoomLevel());
assertEquals(mainModel.getModelData(), modelLink.getLinkedModel());
assertEquals((Integer) 10, modelLink.getxCoord());
assertEquals((Integer) 10, modelLink.getyCoord());
assertEquals((Integer) 3, modelLink.getZoomLevel());
}
private List<ImageZipEntryFile> createImageEntries(String string) throws IOException {
......
......@@ -89,11 +89,11 @@ public class ProjectFactoryTest extends ConverterTestFunctions {
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.getModelData(), mLink.getLinkedModel());
OverviewModelLink modelLink = (OverviewModelLink) link;
assertEquals((Integer) 10, modelLink.getxCoord());
assertEquals((Integer) 10, modelLink.getyCoord());
assertEquals((Integer) 3, modelLink.getZoomLevel());
assertEquals(model.getModelData(), modelLink.getLinkedModel());
}
@Test
......
......@@ -371,8 +371,8 @@ public class CopyCommand extends NewModelCommand {
*/
private void updateReactionReferences(Reaction reaction, Model model) {
reaction.setModel(model);
for (ReactionNode rNode : reaction.getReactionNodes()) {
rNode.setElement(model.getElementByElementId(rNode.getElement().getElementId()));
for (ReactionNode reactionNode : reaction.getReactionNodes()) {
reactionNode.setElement(model.getElementByElementId(reactionNode.getElement().getElementId()));
}
SbmlKinetics kinetics = reaction.getKinetics();
if (kinetics != null) {
......
......@@ -63,7 +63,7 @@ public class ReactionComparator extends Comparator<Reaction> {
protected int internalCompare(Reaction arg0, Reaction arg1) {
StringComparator stringComparator = new StringComparator();
BooleanComparator booleanComparator = new BooleanComparator();
AbstractNodeComparator aNodeComparator = new AbstractNodeComparator(epsilon, ignoreLayout);
AbstractNodeComparator nodeComparator = new AbstractNodeComparator(epsilon, ignoreLayout);
if (stringComparator.compare(arg0.getName(), arg1.getName()) != 0) {
logger.debug("Name different: " + arg0.getName() + ", " + arg1.getName());
......@@ -156,7 +156,7 @@ public class ReactionComparator extends Comparator<Reaction> {
AbstractNode node0 = arg0.getNodes().get(i);
status = -1;
for (int j = 0; j < arg1.getNodes().size(); j++) {
int tmpStatus = aNodeComparator.compare(node0, arg1.getNodes().get(j));
int tmpStatus = nodeComparator.compare(node0, arg1.getNodes().get(j));
if (tmpStatus == 0) {
status = 0;
break;
......
......@@ -220,25 +220,25 @@ public final class ElementUtils {
}
}
List<Class<? extends Reaction>> rTmp = new ArrayList<>();
List<Class<? extends Reaction>> reactionTmp = new ArrayList<>();
reflections = new Reflections("lcsb.mapviewer.model.map.reaction.type");
reactionClasses = new LinkedHashMap<>();
Set<Class<? extends Reaction>> rClasses = reflections.getSubTypesOf(Reaction.class);
Set<Class<? extends Reaction>> allReactionSubClasses = reflections.getSubTypesOf(Reaction.class);
toRemove = new HashSet<>();
for (Class<? extends Reaction> class1 : rClasses) {
for (Class<? extends Reaction> class1 : allReactionSubClasses) {
if (!(class1.isAnonymousClass() || class1.isMemberClass())) {
toRemove.add(class1.getSuperclass());
rTmp.add(class1);
reactionTmp.add(class1);
}
}
for (Class<?> clazz : toRemove) {
rTmp.remove(clazz);
reactionTmp.remove(clazz);
}
for (Class<? extends Reaction> class1 : rTmp) {
for (Class<? extends Reaction> class1 : reactionTmp) {
reactionClasses.put(class1.getSimpleName().replaceAll("Reaction", ""), class1);
try {
String stringType = class1.getConstructor(String.class).newInstance("id").getStringType().toLowerCase();
......
......@@ -52,8 +52,8 @@ public class SearchIndexTest extends ModelTestFunctions {
@Test
public void testCopy() {
SearchIndex aRna = new SearchIndex().copy();
assertNotNull(aRna);
SearchIndex antisenseRna = new SearchIndex().copy();
assertNotNull(antisenseRna);
}
@Test(expected = NotImplementedException.class)
......