Commit e9839c04 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1529-introduce-uniform-checkstyle-validation-as-gitlab-job' into 'master'

Resolve "Introduce uniform checkstyle validation as gitlab job"

See merge request !1328
parents 46fee41d 11ec72b2
Pipeline #47202 passed with stage
in 37 minutes and 33 seconds
......@@ -350,6 +350,18 @@ test:dependency_conflict:
- cat conflicts.txt
- test 0 = $conflicts
test:code_validation:
image: maven:3.6.0-jdk-8
stage: test
script:
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y curl gnupg git ant
- curl -sL https://deb.nodesource.com/setup_9.x | bash -
- DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
- mvn clean compile validate
test:mvn_changelog_version_check:
image: debian
stage: test
......
......@@ -30,6 +30,5 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
......@@ -24,6 +24,5 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
......@@ -3,7 +3,11 @@ package lcsb.mapviewer.cdplugin.copypaste;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import jp.sbi.celldesigner.plugin.*;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
import jp.sbi.celldesigner.plugin.PluginSBase;
import jp.sbi.celldesigner.plugin.PluginSpecies;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.common.SystemClipboard;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
......@@ -29,7 +33,7 @@ public class CopyAction extends CopyPasteAbstractAction {
* @param speciesList
* - list of species to annotate
*/
public void performAnnotation(CopyPastePlugin plug, PluginListOf speciesList) {
public void performAnnotation(final CopyPastePlugin plug, final PluginListOf speciesList) {
SystemClipboard sc = new SystemClipboard();
int size = speciesList.size();
......@@ -66,7 +70,7 @@ public class CopyAction extends CopyPasteAbstractAction {
if (chosenElement != null) {
try {
sc.setClipboardContents(getCopyString(chosenElement.getAnnotationString(), chosenElement.getNotesString()));
} catch (InvalidXmlSchemaException e) {
} catch (final InvalidXmlSchemaException e) {
logger.warn("Problem with creating copy-paste String", e);
}
}
......
......@@ -9,7 +9,9 @@ import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParser;
import lcsb.mapviewer.model.map.*;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamRelationType;
import lcsb.mapviewer.model.map.MiriamType;
/**
* This abstract class defines common function for {@link CopyAction} and
......@@ -38,7 +40,7 @@ public class CopyPasteAbstractAction {
* object to serialize
* @return string representation of {@link MiriamData}
*/
protected String serialize(MiriamData md) {
protected String serialize(final MiriamData md) {
return PREFIX + "\t" + md.getRelationType().getStringRepresentation() + "\t" + md.getDataType().getUris().get(0)
+ "\t" + md.getResource();
}
......@@ -51,7 +53,7 @@ public class CopyPasteAbstractAction {
* string representation of {@link MiriamData}
* @return {@link MiriamData} obtained from input string
*/
protected MiriamData deserialize(String string) {
protected MiriamData deserialize(final String string) {
if (string == null) {
return null;
}
......@@ -86,11 +88,11 @@ public class CopyPasteAbstractAction {
* @throws InvalidXmlSchemaException
* thrown when xmlString is invalid
*/
protected String getCopyString(String annotationString, String notesString) throws InvalidXmlSchemaException {
protected String getCopyString(final String annotationString, final String notesString) throws InvalidXmlSchemaException {
XmlAnnotationParser xap = new XmlAnnotationParser();
Set<MiriamData> set = xap.parse(annotationString, null);
StringBuilder result = new StringBuilder();
for (MiriamData md : set) {
for (final MiriamData md : set) {
result.append(serialize(md) + "\n");
}
result.append(notesString);
......@@ -106,7 +108,7 @@ public class CopyPasteAbstractAction {
*
* @return {@link Pair} of {@link MiriamData} set and notes string
*/
protected Pair<Set<MiriamData>, String> getAnnotationDataFromClipboardString(String value) {
protected Pair<Set<MiriamData>, String> getAnnotationDataFromClipboardString(final String value) {
if (value == null) {
return new Pair<Set<MiriamData>, String>(null, null);
}
......
package lcsb.mapviewer.cdplugin.copypaste;
import java.awt.*;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import org.apache.logging.log4j.LogManager;
......@@ -13,7 +14,7 @@ import jp.sbi.celldesigner.plugin.PluginSBase;
/**
* This class represent a plugin to cell designer with copy past functionality
* that allows to copy and paste notes and annotations of species.
*
* <p>
* It overrides:
* <ul>
* <li>ALT + CTRL + C shortcut - copy annotations from selected element into
......@@ -23,6 +24,7 @@ import jp.sbi.celldesigner.plugin.PluginSBase;
* element(s), if many elements are selected then all elements will be modified,
* </li>
* </ul>
* </p>
*
* @author Piotr Gawron
*
......@@ -64,31 +66,31 @@ public class CopyPastePlugin extends CellDesignerPlugin {
// create keyboard listener for shortcuts
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(createKeyEventDispatcher());
} catch (Exception exception) {
} catch (final Exception exception) {
logger.error(exception, exception);
}
}
protected KeyEventDispatcher createKeyEventDispatcher() {
return new KeyEventDispatcher() {
public boolean dispatchKeyEvent(KeyEvent e) {
public boolean dispatchKeyEvent(final KeyEvent e) {
switch (e.getID()) {
case KeyEvent.KEY_PRESSED:
if (e.getKeyCode() == java.awt.event.KeyEvent.VK_V
&& e.isControlDown()
&& e.isAltDown()) {
getPastePluginAction().myActionPerformed(null);
return true;
} else if (e.getKeyCode() == java.awt.event.KeyEvent.VK_C
&& e.isControlDown()
&& e.isAltDown()) {
getCopyPluginAction().myActionPerformed(null);
return true;
} else {
case KeyEvent.KEY_PRESSED:
if (e.getKeyCode() == java.awt.event.KeyEvent.VK_V
&& e.isControlDown()
&& e.isAltDown()) {
getPastePluginAction().myActionPerformed(null);
return true;
} else if (e.getKeyCode() == java.awt.event.KeyEvent.VK_C
&& e.isControlDown()
&& e.isAltDown()) {
getCopyPluginAction().myActionPerformed(null);
return true;
} else {
return false;
}
default:
return false;
}
default:
return false;
}
}
};
......@@ -100,33 +102,33 @@ public class CopyPastePlugin extends CellDesignerPlugin {
// CHECKSTYLE:OFF
@Override
public void SBaseAdded(PluginSBase arg0) {
public void SBaseAdded(final PluginSBase arg0) {
}
@Override
public void SBaseChanged(PluginSBase arg0) {
public void SBaseChanged(final PluginSBase arg0) {
}
// CHECKSTYLE:ON
@Override
public void SBaseDeleted(PluginSBase arg0) {
public void SBaseDeleted(final PluginSBase arg0) {
}
@Override
public void modelOpened(PluginSBase arg0) {
public void modelOpened(final PluginSBase arg0) {
}
@Override
public void modelSelectChanged(PluginSBase arg0) {
public void modelSelectChanged(final PluginSBase arg0) {
}
@Override
public void modelClosed(PluginSBase arg0) {
public void modelClosed(final PluginSBase arg0) {
}
......
......@@ -39,17 +39,17 @@ public class CopyPluginAction extends PluginAction {
* @param win
* {@link #window}
*/
public CopyPluginAction(CopyPastePlugin plugin, MainWindow win) {
public CopyPluginAction(final CopyPastePlugin plugin, final MainWindow win) {
this.plugin = plugin;
}
@Override
public void myActionPerformed(ActionEvent e) {
public void myActionPerformed(final ActionEvent e) {
try {
CopyAction annotateAction = new CopyAction();
PluginListOf list = getPlugin().getSelectedAllNode();
annotateAction.performAnnotation(getPlugin(), list);
} catch (Exception ex) {
} catch (final Exception ex) {
logger.error(ex, ex);
}
}
......@@ -58,7 +58,7 @@ public class CopyPluginAction extends PluginAction {
return plugin;
}
protected void setPlugin(CopyPastePlugin plugin) {
protected void setPlugin(final CopyPastePlugin plugin) {
this.plugin = plugin;
}
......
......@@ -5,7 +5,11 @@ import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import jp.sbi.celldesigner.plugin.*;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
import jp.sbi.celldesigner.plugin.PluginSBase;
import jp.sbi.celldesigner.plugin.PluginSpecies;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.common.Pair;
import lcsb.mapviewer.common.SystemClipboard;
import lcsb.mapviewer.converter.annotation.XmlAnnotationParser;
......@@ -33,7 +37,7 @@ public class PasteAction extends CopyPasteAbstractAction {
* @param speciesList
* - list of species to annotate
*/
public void performAnnotation(CopyPastePlugin plug, PluginListOf speciesList) {
public void performAnnotation(final CopyPastePlugin plug, final PluginListOf speciesList) {
XmlAnnotationParser xap = new XmlAnnotationParser();
SystemClipboard sc = new SystemClipboard();
......
......@@ -39,17 +39,17 @@ public class PastePluginAction extends PluginAction {
* @param win
* {@link #window}
*/
public PastePluginAction(CopyPastePlugin plugin, MainWindow win) {
public PastePluginAction(final CopyPastePlugin plugin, final MainWindow win) {
this.setPlugin(plugin);
}
@Override
public void myActionPerformed(ActionEvent e) {
public void myActionPerformed(final ActionEvent e) {
try {
PasteAction annotateAction = new PasteAction();
PluginListOf list = getPlugin().getSelectedAllNode();
annotateAction.performAnnotation(plugin, list);
} catch (Exception ex) {
} catch (final Exception ex) {
logger.error(ex, ex);
}
}
......@@ -58,7 +58,7 @@ public class PastePluginAction extends PluginAction {
return plugin;
}
protected void setPlugin(CopyPastePlugin plugin) {
protected void setPlugin(final CopyPastePlugin plugin) {
this.plugin = plugin;
}
......
package lcsb.mapviewer.cdplugin.info;
import java.awt.*;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -124,7 +136,7 @@ public final class InfoFrame {
JPanel controlArea = new JPanel(new GridLayout(panels, 1));
controlArea.setLayout(new BoxLayout(controlArea, BoxLayout.Y_AXIS));
// for every species create a panel and add it to general form
for (PluginSpeciesAlias sp : this.species) {
for (final PluginSpeciesAlias sp : this.species) {
JPanel panel = getPanelViewForSpecies(sp);
controlArea.add(panel);
}
......@@ -155,7 +167,7 @@ public final class InfoFrame {
* CellDesigner species alias
* @return {@link JPanel} object with information about species
*/
private JPanel getPanelViewForSpecies(PluginSpeciesAlias species) {
private JPanel getPanelViewForSpecies(final PluginSpeciesAlias species) {
JPanel result = new JPanel();
result.setLayout(new BoxLayout(result, BoxLayout.Y_AXIS));
......@@ -202,7 +214,7 @@ public final class InfoFrame {
* @param visible
* should the frame be visible or not
*/
public void setVisible(boolean visible) {
public void setVisible(final boolean visible) {
frame.setVisible(visible);
}
......@@ -212,7 +224,7 @@ public final class InfoFrame {
* @param title
* title of the frame
*/
public void setTitle(String title) {
public void setTitle(final String title) {
frame.setTitle(title);
}
......@@ -231,7 +243,7 @@ public final class InfoFrame {
* @param type
* new {@link JFrame#defaultCloseOperation} value
*/
public void setDefaultCloseOperation(int type) {
public void setDefaultCloseOperation(final int type) {
frame.setDefaultCloseOperation(type);
}
......@@ -241,7 +253,7 @@ public final class InfoFrame {
* @param always
* new {@link JFrame#isAlwaysOnTop()} value
*/
public void setAlwaysOnTop(boolean always) {
public void setAlwaysOnTop(final boolean always) {
frame.setAlwaysOnTop(always);
}
......@@ -255,7 +267,7 @@ public final class InfoFrame {
* @param species
* - species to be shown in the form
*/
public void setSpecies(List<PluginSpeciesAlias> species) {
public void setSpecies(final List<PluginSpeciesAlias> species) {
this.species = species;
updateSpecies();
}
......
package lcsb.mapviewer.cdplugin.info;
import java.awt.*;
import java.awt.event.*;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.Timer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import jp.sbi.celldesigner.plugin.*;
import jp.sbi.celldesigner.plugin.CellDesignerPlugin;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginSBase;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
/**
* This class represent a plugin to CellDesigner that add info text box with
* informations about species. Plugin run in pooling mode (there is no other way
* in CellDesigner...).
*
* <p>
* It overrides <i>CTRL + T shortcut</i> - shows/hide info text window.
* </p>
*
* @author Piotr Gawron
*
......@@ -64,7 +71,7 @@ public class InfoPlugin extends CellDesignerPlugin {
// create keyboard listener for shortcuts
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
public boolean dispatchKeyEvent(KeyEvent e) {
public boolean dispatchKeyEvent(final KeyEvent e) {
if (KeyEvent.KEY_PRESSED == e.getID()) {
// if someone hits CTRL+T then open/hide info window
if (e.getKeyCode() == java.awt.event.KeyEvent.VK_T
......@@ -81,14 +88,14 @@ public class InfoPlugin extends CellDesignerPlugin {
onChangeSelectListener = new ActionListener() {
/**
* This string contains a simple hash of all species shown in the last run of
* this listener. Due to this information we don't have to refresh this
* information at every run.
* This string contains a simple hash of all species shown in the last
* run of this listener. Due to this information we don't have to
* refresh this information at every run.
*/
private String selectedElementsId = "";
@Override
public void actionPerformed(ActionEvent arg0) {
public void actionPerformed(final ActionEvent arg0) {
// if there is no open model then getSelectedAllNode() will throw an
// exception...
List<PluginSpeciesAlias> aliasList = getListOfAlias();
......@@ -107,7 +114,7 @@ public class InfoPlugin extends CellDesignerPlugin {
selectedElementsId = newId;
frame.setSpecies(v);
}
} catch (Exception exception) {
} catch (final Exception exception) {
logger.error(exception, exception);
}
......@@ -117,7 +124,7 @@ public class InfoPlugin extends CellDesignerPlugin {
Timer timer = new Timer(DELAY_BETWEEN_ON_SELECT_LISTENER_CHECKS, onChangeSelectListener);
timer.start();
} catch (Exception exception) {
} catch (final Exception exception) {
logger.error("Unhandled exception. ", exception);
}
}
......@@ -128,33 +135,33 @@ public class InfoPlugin extends CellDesignerPlugin {
// CHECKSTYLE:OFF
@Override
public void SBaseAdded(PluginSBase arg0) {
public void SBaseAdded(final PluginSBase arg0) {
}
@Override
public void SBaseChanged(PluginSBase arg0) {
public void SBaseChanged(final PluginSBase arg0) {
}
// CHECKSTYLE:ON
@Override
public void SBaseDeleted(PluginSBase arg0) {
public void SBaseDeleted(final PluginSBase arg0) {
}
@Override
public void modelOpened(PluginSBase arg0) {
public void modelOpened(final PluginSBase arg0) {
}
@Override
public void modelSelectChanged(PluginSBase arg0) {
public void modelSelectChanged(final PluginSBase arg0) {
}
@Override
public void modelClosed(PluginSBase arg0) {
public void modelClosed(final PluginSBase arg0) {
}
......@@ -169,7 +176,7 @@ public class InfoPlugin extends CellDesignerPlugin {
result.add(alias);
}
}
} catch (Exception e) {
} catch (final Exception e) {
}
return result;
}
......
......@@ -3,28 +3,32 @@ package lcsb.mapviewer.cdplugin;
import java.util.List;
import org.apache.logging.log4j.core.LogEvent;
import org.junit.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.Mockito;
import jp.sbi.celldesigner.plugin.*;
import jp.sbi.celldesigner.plugin.PluginListOf;
import jp.sbi.celldesigner.plugin.PluginReaction;
import jp.sbi.celldesigner.plugin.PluginSpecies;
import jp.sbi.celldesigner.plugin.PluginSpeciesAlias;
import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.common.UnitTestFailedWatcher;
import lcsb.mapviewer.common.tests.UnitTestFailedWatcher;
public class CdPluginFunctions {
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
String rdfString = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
+
"<rdf:Description rdf:about=\"#s3\">\n" +
"<bqmodel:is>\n" +
"<rdf:Bag>\n" +
"<rdf:li rdf:resource=\"urn:miriam:wikipedia.en:1\"/>\n" +
"</rdf:Bag>\n" +
"</bqmodel:is>\n" +
"</rdf:Description>\n" +
"</rdf:RDF>\n";
private String rdfString = "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
+ "<rdf:Description rdf:about=\"#s3\">\n"
+ "<bqmodel:is>\n"
+ "<rdf:Bag>\n"
+ "<rdf:li rdf:resource=\"urn:miriam:wikipedia.en:1\"/>\n"
+ "</rdf:Bag>\n"
+ "</bqmodel:is>\n"
+ "</rdf:Description>\n"
+ "</rdf:RDF>\n";
private MinervaLoggerAppender appender;
......@@ -51,7 +55,7 @@ public class CdPluginFunctions {
return appender.getFatals();
}
protected PluginListOf createPluginListWithSpecies(int size) {
protected PluginListOf createPluginListWithSpecies(final int size) {
PluginListOf list = Mockito.mock(PluginListOf.class);
Mockito.when(list.size()).thenReturn(size);
......@@ -62,7 +66,7 @@ public class CdPluginFunctions {
return list;
}