Skip to content

Commit

Permalink
Start of inplementation for constraints 10202-10205.
Browse files Browse the repository at this point in the history
  • Loading branch information
niko-rodrigue committed Aug 3, 2018
1 parent d71da51 commit 7ed6c9d
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 3 deletions.
Expand Up @@ -19,8 +19,10 @@
*/
package org.sbml.jsbml.validator.offline.constraints;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -59,6 +61,12 @@ public class ASTNodeConstraints extends AbstractConstraintDeclaration {
*/
private static transient Logger logger = Logger.getLogger(ASTNodeConstraints.class);

/**
*
*/
public static final transient List<String> allowedCsymbolURI = Arrays.asList(ASTNode.URI_AVOGADRO_DEFINITION, ASTNode.URI_DELAY_DEFINITION, ASTNode.URI_RATE_OF_DEFINITION, ASTNode.URI_TIME_DEFINITION);


/*
* (non-Javadoc)
* @see org.sbml.jsbml.validator.offline.constraints.ConstraintDeclaration#
Expand Down Expand Up @@ -165,7 +173,81 @@ public boolean check(ValidationContext ctx, ASTNode node) {
};
break;
}

case CORE_10202: {
func = new ValidationFunction<ASTNode>() {

@Override
public boolean check(ValidationContext ctx, ASTNode node) {

// TODO - check allowed mathML elements
if (node.getType().equals(ASTNode.Type.UNKNOWN)) {
// TODO - have a proper message with the name of the offending element.
return false;
}

return true;
}
};
break;
}
case CORE_10203: {
func = new ValidationFunction<ASTNode>() {

@Override
public boolean check(ValidationContext ctx, ASTNode node) {

// encoding only on some element
if (node.isSetEncoding() &&
!(node.getType() == ASTNode.Type.FUNCTION_DELAY || node.getType() == ASTNode.Type.FUNCTION_RATE_OF
|| node.getType() == ASTNode.Type.NAME_TIME || node.getType() == ASTNode.Type.NAME_AVOGADRO))
{
// TODO - who to recognize annotation and annotation-xml ?
return false;
}

return true;
}
};
break;
}
case CORE_10204: {
func = new ValidationFunction<ASTNode>() {

@Override
public boolean check(ValidationContext ctx, ASTNode node) {

// TODO - ci is only allowed since L2V5/L3

// definitionURL only on some elements
if (node.isSetDefinitionURL() &&
!(node.isSemantics() || node.isName() || node.getType() == ASTNode.Type.FUNCTION_DELAY
|| node.getType() == ASTNode.Type.FUNCTION_RATE_OF))
{
return false;
}

return true;
}
};
break;
}
case CORE_10205: {
func = new ValidationFunction<ASTNode>() {

@Override
public boolean check(ValidationContext ctx, ASTNode node) {

// check allowed values for definitionURL
if (node.isSetDefinitionURL() && !allowedCsymbolURI.contains(node.getDefinitionURL())) {
return false;
}

return true;
}
};
break;
}

case CORE_10208:
func = new ValidationFunction<ASTNode>() {

Expand Down
Expand Up @@ -31,7 +31,6 @@
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.JOptionPane;
import javax.swing.tree.TreeNode;

import org.sbml.jsbml.ListOf;
Expand All @@ -44,7 +43,6 @@
import org.sbml.jsbml.validator.offline.LoggingValidationContext;
import org.sbml.jsbml.validator.offline.factory.SBMLErrorCodes;
import org.sbml.jsbml.xml.stax.SBMLReader;
import org.sbml.libsbml.libsbml;
import org.sbml.libsbml.libsbmlConstants;

/**
Expand Down

0 comments on commit 7ed6c9d

Please sign in to comment.