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

overriden methods should be grouped together

parent a065c619
...@@ -237,6 +237,22 @@ public class ModelAnnotator { ...@@ -237,6 +237,22 @@ public class ModelAnnotator {
return defaultAnnotators; return defaultAnnotators;
} }
/**
* Returns list of default {@link ElementAnnotator} names that are available for
* class given in the parameter.
*
* @param clazz
* class for which list of default annotators will be returned
* @return annotators names for a given class
*/
public List<AnnotatorData> getDefaultAnnotators(final Class<?> clazz) {
List<AnnotatorData> result = new ArrayList<>();
for (final ElementAnnotator annotator : getAvailableDefaultAnnotators(clazz)) {
result.add(annotator.createAnnotatorData());
}
return result;
}
/** /**
* This method returns list of improper annotations for the model. Improper * This method returns list of improper annotations for the model. Improper
* annotation is the annotation of the wrong type for given type of element. * annotation is the annotation of the wrong type for given type of element.
...@@ -411,22 +427,6 @@ public class ModelAnnotator { ...@@ -411,22 +427,6 @@ public class ModelAnnotator {
return result; return result;
} }
/**
* Returns list of default {@link ElementAnnotator} names that are available for
* class given in the parameter.
*
* @param clazz
* class for which list of default annotators will be returned
* @return annotators names for a given class
*/
public List<AnnotatorData> getDefaultAnnotators(final Class<?> clazz) {
List<AnnotatorData> result = new ArrayList<>();
for (final ElementAnnotator annotator : getAvailableDefaultAnnotators(clazz)) {
result.add(annotator.createAnnotatorData());
}
return result;
}
/** /**
* Returns list of default {@link ElementAnnotator annotators} that are * Returns list of default {@link ElementAnnotator annotators} that are
* available for class given in the parameter. * available for class given in the parameter.
......
...@@ -284,6 +284,20 @@ public class PubmedParser extends CachableInterface implements IExternalService ...@@ -284,6 +284,20 @@ public class PubmedParser extends CachableInterface implements IExternalService
return result; return result;
} }
/**
* Get the summary of the article.
*
* @param id
* pubmed identifier
* @return summary of the article.
* @throws PubmedSearchException
* thrown when there is a problem with accessing information about
* pubmed
*/
public String getSummary(final String id) throws PubmedSearchException {
return getSummary(Integer.valueOf(id));
}
@Override @Override
public ExternalServiceStatus getServiceStatus() { public ExternalServiceStatus getServiceStatus() {
ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central", ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central",
...@@ -339,20 +353,6 @@ public class PubmedParser extends CachableInterface implements IExternalService ...@@ -339,20 +353,6 @@ public class PubmedParser extends CachableInterface implements IExternalService
} }
} }
/**
* Get the summary of the article.
*
* @param id
* pubmed identifier
* @return summary of the article.
* @throws PubmedSearchException
* thrown when there is a problem with accessing information about
* pubmed
*/
public String getSummary(final String id) throws PubmedSearchException {
return getSummary(Integer.valueOf(id));
}
/** /**
* @return the miriamConnector * @return the miriamConnector
* @see #miriamConnector * @see #miriamConnector
......
...@@ -181,6 +181,24 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -181,6 +181,24 @@ public abstract class ElementAnnotator extends CachableInterface {
return false; return false;
} }
/**
* Returns <code>true</code> if this annotator can annotate the object of
* given class type.
*
* @param clazz
* class to be tested if can be annotated
* @return <code>true</code> if class can be annotated by this annotator,
* <code>false</code> otherwise
*/
public boolean isAnnotatable(final Class<?> clazz) {
for (final Class<?> clazz2 : validClasses) {
if (clazz2.isAssignableFrom(clazz)) {
return true;
}
}
return false;
}
/** /**
* Adds a class to list of classes that can be annotated by the annotator. * Adds a class to list of classes that can be annotated by the annotator.
* *
...@@ -235,24 +253,6 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -235,24 +253,6 @@ public abstract class ElementAnnotator extends CachableInterface {
this.paramsDefs = paramDefs; this.paramsDefs = paramDefs;
} }
/**
* Returns <code>true</code> if this annotator can annotate the object of
* given class type.
*
* @param clazz
* class to be tested if can be annotated
* @return <code>true</code> if class can be annotated by this annotator,
* <code>false</code> otherwise
*/
public boolean isAnnotatable(final Class<?> clazz) {
for (final Class<?> clazz2 : validClasses) {
if (clazz2.isAssignableFrom(clazz)) {
return true;
}
}
return false;
}
/** /**
* *
* @return {@link #isDefault} * @return {@link #isDefault}
...@@ -362,6 +362,24 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -362,6 +362,24 @@ public abstract class ElementAnnotator extends CachableInterface {
} }
} }
public void addMiriamData(final MiriamType miriamType, final String resource) {
addMiriamData(new MiriamData(miriamType, resource));
}
public void addMiriamData(final String generalIdentifier) {
MiriamData md = null;
try {
md = MiriamType.getMiriamByUri(generalIdentifier);
} catch (final InvalidArgumentException e) {
try {
md = MiriamType.getMiriamByUri("urn:miriam:" + generalIdentifier);
} catch (final InvalidArgumentException e1) {
logger.warn(getLogMarker(ProjectLogEntryType.INVALID_IDENTIFIER), "Unknown miriam uri: " + generalIdentifier);
}
}
addMiriamData(md);
}
public boolean contains(final MiriamData identifier) { public boolean contains(final MiriamData identifier) {
MiriamData copy = new MiriamData(identifier); MiriamData copy = new MiriamData(identifier);
copy.setAnnotator(null); copy.setAnnotator(null);
...@@ -531,20 +549,6 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -531,20 +549,6 @@ public abstract class ElementAnnotator extends CachableInterface {
} }
} }
public void addMiriamData(final String generalIdentifier) {
MiriamData md = null;
try {
md = MiriamType.getMiriamByUri(generalIdentifier);
} catch (final InvalidArgumentException e) {
try {
md = MiriamType.getMiriamByUri("urn:miriam:" + generalIdentifier);
} catch (final InvalidArgumentException e1) {
logger.warn(getLogMarker(ProjectLogEntryType.INVALID_IDENTIFIER), "Unknown miriam uri: " + generalIdentifier);
}
}
addMiriamData(md);
}
/** /**
* Sets {@link CellDesignerChemical#inChI}. * Sets {@link CellDesignerChemical#inChI}.
* *
...@@ -598,10 +602,6 @@ public abstract class ElementAnnotator extends CachableInterface { ...@@ -598,10 +602,6 @@ public abstract class ElementAnnotator extends CachableInterface {
} }
} }
public void addMiriamData(final MiriamType miriamType, final String resource) {
addMiriamData(new MiriamData(miriamType, resource));
}
/** /**
* Sets {@link Species#charge}. * Sets {@link Species#charge}.
* *
......
...@@ -129,6 +129,11 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto ...@@ -129,6 +129,11 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
} }
} }
@Override
public String getAuthenticatedContent(final String string) throws DapiConnectionException {
return getAuthenticatedContent(string, true);
}
@Override @Override
public String getLatestReleaseUrl(final String databaseName) throws DapiConnectionException { public String getLatestReleaseUrl(final String databaseName) throws DapiConnectionException {
String release = getLatestReleaseAvailable(databaseName); String release = getLatestReleaseAvailable(databaseName);
...@@ -138,11 +143,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto ...@@ -138,11 +143,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
return DAPI_BASE_URL + "database/" + databaseName + "/releases/" + getLatestReleaseAvailable(databaseName) + "/"; return DAPI_BASE_URL + "database/" + databaseName + "/releases/" + getLatestReleaseAvailable(databaseName) + "/";
} }
@Override
public String getAuthenticatedContent(final String string) throws DapiConnectionException {
return getAuthenticatedContent(string, true);
}
@Override @Override
public boolean isAuthenticated() { public boolean isAuthenticated() {
Calendar nowMinus10Minutes = Calendar.getInstance(); Calendar nowMinus10Minutes = Calendar.getInstance();
...@@ -171,10 +171,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto ...@@ -171,10 +171,6 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
} }
} }
public String getDapiPassword() {
return configurationDao.getValueByType(ConfigurationElementType.DAPI_PASSWORD);
}
void login(final String login, final String password) void login(final String login, final String password)
throws MalformedURLException, IOException, ProtocolException, DapiConnectionException { throws MalformedURLException, IOException, ProtocolException, DapiConnectionException {
if (login == null || password == null) { if (login == null || password == null) {
...@@ -203,6 +199,10 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto ...@@ -203,6 +199,10 @@ public class DapiConnectorImpl extends CachableInterface implements DapiConnecto
} }
} }
public String getDapiPassword() {
return configurationDao.getValueByType(ConfigurationElementType.DAPI_PASSWORD);
}
@Override @Override
public boolean isValidConnection() { public boolean isValidConnection() {
if (getDapiLogin() == null || getDapiLogin().isEmpty() || getDapiPassword() == null if (getDapiLogin() == null || getDapiLogin().isEmpty() || getDapiPassword() == null
......
...@@ -222,15 +222,9 @@ ...@@ -222,15 +222,9 @@
<property name="lineWrappingIndentation" value="4"/> <property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/> <property name="arrayInitIndent" value="2"/>
</module> </module>
<!-- <module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
</module>
<module name="OverloadMethodsDeclarationOrder"/> <module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/> <!-- <module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder"> <module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/> <property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/> <property name="separateLineBetweenGroups" value="true"/>
...@@ -304,9 +298,17 @@ ...@@ -304,9 +298,17 @@
<module name="CommentsIndentation"> <module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/> <property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
</module> </module>
<module name="VisibilityModifier"> <module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/> <property name="protectedAllowed" value="true"/>
</module> --> </module>
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/>
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
</module>
-->
</module> </module>
</module> </module>
...@@ -168,18 +168,6 @@ public final class Configuration { ...@@ -168,18 +168,6 @@ public final class Configuration {
return systemBuildVersion; return systemBuildVersion;
} }
/**
* @param baseDir
* directory where the system is placed
* @return {@link #systemVersion}
*/
public static String getSystemVersion(final String baseDir) {
if (systemVersion == null) {
loadSystemVersion(baseDir);
}
return systemVersion;
}
/** /**
* @param baseDir * @param baseDir
* directory where the system is placed * directory where the system is placed
...@@ -194,6 +182,18 @@ public final class Configuration { ...@@ -194,6 +182,18 @@ public final class Configuration {
return getSystemBuildVersion(baseDir); return getSystemBuildVersion(baseDir);
} }
/**
* @param baseDir
* directory where the system is placed
* @return {@link #systemVersion}
*/
public static String getSystemVersion(final String baseDir) {
if (systemVersion == null) {
loadSystemVersion(baseDir);
}
return systemVersion;
}
/** /**
* @param baseDir * @param baseDir
* directory where the system is placed * directory where the system is placed
......
...@@ -346,6 +346,91 @@ public class RestAnnotationParser { ...@@ -346,6 +346,91 @@ public class RestAnnotationParser {
processNotes(notes, element); processNotes(notes, element);
} }
/**
* Process notes and assign structural information from it.
*
* @param element
* object with notes to be processed
*/
public void processNotes(final Element element) {
processNotes(element.getNotes(), element);
}
/**
* Process notes and assign structural information from it.
*
* @param notes
* notes about element
* @param object
* where the structural data should be put
*/
public void processNotes(final String notes, final Drawable object) {
StringBuilder annotations = new StringBuilder();
String[] string = notes.split("\n");
StringBuilder newNotes = new StringBuilder("");
for (final String string2 : string) {
boolean remove = false;
for (final NoteField field : NoteField.values()) {
if (string2.startsWith(field.getCommonName() + ":") && field.getClazz().isAssignableFrom(object.getClass())) {
remove = true;
} else if (string2.startsWith(field.getCommonName() + "=")
&& field.getClazz().isAssignableFrom(object.getClass())) {
remove = true;
}
}
if (remove) {
annotations.append(string2 + "\n");
} else {
newNotes.append(string2 + "\n");
}
}
String ann = annotations.toString();
setZIndex(object, ann);
if (object instanceof LayerText) {
LayerText layerText = (LayerText) object;
setBackgroundColor(layerText, ann);
setBorderColor(layerText, ann);
layerText.setNotes(newNotes.toString().trim());
}
if (object instanceof BioEntity) {
BioEntity bioEntity = (BioEntity) object;
bioEntity.setNotes(newNotes.toString().trim());
setNotes(bioEntity, ann);
setSymbol(bioEntity, ann);
setSynonyms(bioEntity, ann);
setSemanticZoomLevelVisibility(bioEntity, ann);
setAbbreviation(bioEntity, ann);
setFormula(bioEntity, ann);
if (object instanceof Reaction) {
Reaction reaction = (Reaction) object;
setMechanicalConfidenceScoreToReaction(reaction, ann);
setLowerBoundToReaction(reaction, ann);
setUpperBoundToReaction(reaction, ann);
setSubsystemToReaction(reaction, ann);
setGeneProteinReactionToReaction(reaction, ann);
} else if (object instanceof Element) {
setTransparencyZoomLevelVisibility((Element) object, ann);
setFullNameToSpecies((Element) object, ann);
setFormerSymbolsToSpecies((Element) object, ann);
if (object instanceof Species) {
setCharge((Species) object, ann);
}
} else {
throw new NotImplementedException("Don't know how to process class: " + object.getClass());
}
try {
processRdfDescription(bioEntity);
} catch (final InvalidXmlSchemaException e) {
String warning = elementUtils.getElementTag(object) + " Problem with processing notes. Invalid RDF node.";
logger.warn(warning);
}
}
}
/** /**
* Transforms xml node into notes. * Transforms xml node into notes.
* *
...@@ -767,81 +852,6 @@ public class RestAnnotationParser { ...@@ -767,81 +852,6 @@ public class RestAnnotationParser {
return getParamByPrefix(annotationString, NoteField.DESCRIPTION.getCommonName() + ":"); return getParamByPrefix(annotationString, NoteField.DESCRIPTION.getCommonName() + ":");
} }
/**
* Process notes and assign structural information from it.
*
* @param notes
* notes about element
* @param object
* where the structural data should be put
*/
public void processNotes(final String notes, final Drawable object) {
StringBuilder annotations = new StringBuilder();
String[] string = notes.split("\n");
StringBuilder newNotes = new StringBuilder("");
for (final String string2 : string) {
boolean remove = false;
for (final NoteField field : NoteField.values()) {
if (string2.startsWith(field.getCommonName() + ":") && field.getClazz().isAssignableFrom(object.getClass())) {
remove = true;
} else if (string2.startsWith(field.getCommonName() + "=")
&& field.getClazz().isAssignableFrom(object.getClass())) {
remove = true;
}
}
if (remove) {
annotations.append(string2 + "\n");
} else {
newNotes.append(string2 + "\n");
}
}
String ann = annotations.toString();
setZIndex(object, ann);
if (object instanceof LayerText) {
LayerText layerText = (LayerText) object;
setBackgroundColor(layerText, ann);
setBorderColor(layerText, ann);
layerText.setNotes(newNotes.toString().trim());
}
if (object instanceof BioEntity) {
BioEntity bioEntity = (BioEntity) object;
bioEntity.setNotes(newNotes.toString().trim());
setNotes(bioEntity, ann);
setSymbol(bioEntity, ann);
setSynonyms(bioEntity, ann);
setSemanticZoomLevelVisibility(bioEntity, ann);
setAbbreviation(bioEntity, ann);
setFormula(bioEntity, ann);
if (object instanceof Reaction) {
Reaction reaction = (Reaction) object;
setMechanicalConfidenceScoreToReaction(reaction, ann);
setLowerBoundToReaction(reaction, ann);
setUpperBoundToReaction(reaction, ann);
setSubsystemToReaction(reaction, ann);
setGeneProteinReactionToReaction(reaction, ann);
} else if (object instanceof Element) {
setTransparencyZoomLevelVisibility((Element) object, ann);
setFullNameToSpecies((Element) object, ann);
setFormerSymbolsToSpecies((Element) object, ann);
if (object instanceof Species) {
setCharge((Species) object, ann);
}
} else {
throw new NotImplementedException("Don't know how to process class: " + object.getClass());
}
try {
processRdfDescription(bioEntity);
} catch (final InvalidXmlSchemaException e) {
String warning = elementUtils.getElementTag(object) + " Problem with processing notes. Invalid RDF node.";