From 8befb99200f9d9e120bd456cba30044d01148ecc Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Wed, 23 Sep 2015 17:15:04 +0100 Subject: [PATCH] some changes --- validator/pom.xml | 242 ++++ .../java/psidev/psi/ms/ClusteredContext.java | 44 + .../psi/ms/ExtendedValidatorReport.java | 280 ++++ .../psidev/psi/ms/MzMLSchemaValidator.java | 195 +++ .../psi/ms/MzMLValidationErrorHandler.java | 164 +++ .../java/psidev/psi/ms/MzMLValidator.java | 1245 +++++++++++++++++ .../java/psidev/psi/ms/MzMLValidatorGUI.form | 456 ++++++ .../java/psidev/psi/ms/MzMLValidatorGUI.java | 957 +++++++++++++ .../main/java/psidev/psi/ms/Resources.java | 100 ++ .../java/psidev/psi/ms/ValidationType.java | 14 + .../mapping/jaxb/AcquisitionListType.java | 239 ++++ .../ms/mzml/mapping/jaxb/AcquisitionType.java | 190 +++ .../mapping/jaxb/BinaryDataArrayType.java | 236 ++++ .../psi/ms/mzml/mapping/jaxb/CVListType.java | 177 +++ .../psi/ms/mzml/mapping/jaxb/CVParamType.java | 291 ++++ .../psi/ms/mzml/mapping/jaxb/CVType.java | 225 +++ .../mzml/mapping/jaxb/ComponentListType.java | 191 +++ .../ms/mzml/mapping/jaxb/ComponentType.java | 133 ++ .../psi/ms/mzml/mapping/jaxb/ContactType.java | 98 ++ .../mapping/jaxb/DataProcessingListType.java | 177 +++ .../mzml/mapping/jaxb/DataProcessingType.java | 327 +++++ .../mzml/mapping/jaxb/FileChecksumType.java | 166 +++ .../mapping/jaxb/FileDescriptionType.java | 215 +++ .../mzml/mapping/jaxb/InstrumentListType.java | 177 +++ .../jaxb/InstrumentSoftwareRefType.java | 130 ++ .../ms/mzml/mapping/jaxb/InstrumentType.java | 208 +++ .../psi/ms/mzml/mapping/jaxb/MzMLType.java | 476 +++++++ .../ms/mzml/mapping/jaxb/ObjectFactory.java | 426 ++++++ .../mzml/mapping/jaxb/ParamGroupRefType.java | 182 +++ .../ms/mzml/mapping/jaxb/ParamGroupType.java | 241 ++++ .../mzml/mapping/jaxb/PrecursorListType.java | 176 +++ .../ms/mzml/mapping/jaxb/PrecursorType.java | 208 +++ .../jaxb/ReferenceableParamGroupListType.java | 177 +++ .../jaxb/ReferenceableParamGroupType.java | 138 ++ .../psi/ms/mzml/mapping/jaxb/RunType.java | 591 ++++++++ .../ms/mzml/mapping/jaxb/SampleListType.java | 177 +++ .../psi/ms/mzml/mapping/jaxb/SampleType.java | 166 +++ .../psi/ms/mzml/mapping/jaxb/ScanType.java | 82 ++ .../mzml/mapping/jaxb/SoftwareListType.java | 559 ++++++++ .../ms/mzml/mapping/jaxb/SoftwareType.java | 39 + .../mzml/mapping/jaxb/SourceFileListType.java | 177 +++ .../ms/mzml/mapping/jaxb/SourceFileType.java | 238 ++++ .../mapping/jaxb/SpectrumDescriptionType.java | 651 +++++++++ .../mzml/mapping/jaxb/SpectrumListType.java | 176 +++ .../ms/mzml/mapping/jaxb/SpectrumType.java | 319 +++++ .../ms/mzml/mapping/jaxb/UserParamType.java | 194 +++ .../ms/mzml/mapping/jaxb/package-info.java | 9 + ...cquisitionParametersFileRefObjectRule.java | 90 ++ ...plicitAcquisitionParametersObjectRule.java | 114 ++ .../InstrumentConfigurationObjectRule.java | 156 +++ .../LaserWavelengthObjectRule.java | 76 + .../MandatoryElementsObjectRule.java | 42 + ...rameterFileInSourceFileListObjectRule.java | 153 ++ .../MatrixSolutionObjectRule.java | 77 + .../object_rules/OtherSourceObjectRule.java | 109 ++ ...rameterFileInSourceFileListObjectRule.java | 93 ++ .../object_rules/SoftwareListObjectRule.java | 119 ++ .../ms/object_rules/SpectrumObjectRule.java | 252 ++++ .../ms/object_rules/TemplateObjectRule.java | 45 + .../ms/object_rules/util/ObjectRuleUtil.java | 45 + .../ms/rulefilter/MaldiOrEsiCondition.java | 18 + .../psi/ms/rulefilter/RuleFilterAgent.java | 27 + .../psi/ms/rulefilter/RuleFilterManager.java | 545 ++++++++ .../jaxb/CvMappingRuleCondition.java | 155 ++ .../jaxb/CvMappingRuleConditions.java | 78 ++ .../rulefilter/jaxb/CvMappingRuleToSkip.java | 67 + .../ms/rulefilter/jaxb/MandatoryElements.java | 108 ++ .../jaxb/MandatoryMzIdentMLElement.java | 67 + .../rulefilter/jaxb/MandatoryMzMLElement.java | 67 + .../psi/ms/rulefilter/jaxb/ObjectFactory.java | 167 +++ .../rulefilter/jaxb/ObjectRuleCondition.java | 155 ++ .../rulefilter/jaxb/ObjectRuleConditions.java | 78 ++ .../ms/rulefilter/jaxb/ObjectRuleToSkip.java | 67 + .../ms/rulefilter/jaxb/ReferencedRules.java | 138 ++ .../psi/ms/rulefilter/jaxb/References.java | 78 ++ .../psi/ms/rulefilter/jaxb/RuleFilter.java | 179 +++ .../ms/rulefilter/jaxb/RulesToSkipRef.java | 67 + .../psi/ms/rulefilter/jaxb/UserCondition.java | 106 ++ .../ms/rulefilter/jaxb/UserConditions.java | 76 + .../psi/ms/rulefilter/jaxb/UserOption.java | 168 +++ .../psi/ms/swingworker/SwingWorker.java | 150 ++ validator/src/main/resources/ObjectRules.xml | 6 + .../src/main/resources/ObjectRulesMIAPE.xml | 14 + .../main/resources/defaultMzMLElement.cfg.xml | 429 ++++++ validator/src/main/resources/log4j.properties | 7 + .../src/main/resources/miape-ms-rules.xml | 288 ++++ validator/src/main/resources/ms-mapping.xml | 188 +++ validator/src/main/resources/ontologies.xml | 15 + .../src/main/resources/ruleFilterMIAPE.xml | 58 + .../src/main/resources/validation.properties | 6 + .../psi/ms/rulefilter/RuleFilterTest.java | 56 + 91 files changed, 17278 insertions(+) create mode 100644 validator/pom.xml create mode 100644 validator/src/main/java/psidev/psi/ms/ClusteredContext.java create mode 100644 validator/src/main/java/psidev/psi/ms/ExtendedValidatorReport.java create mode 100644 validator/src/main/java/psidev/psi/ms/MzMLSchemaValidator.java create mode 100644 validator/src/main/java/psidev/psi/ms/MzMLValidationErrorHandler.java create mode 100644 validator/src/main/java/psidev/psi/ms/MzMLValidator.java create mode 100644 validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.form create mode 100644 validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.java create mode 100644 validator/src/main/java/psidev/psi/ms/Resources.java create mode 100644 validator/src/main/java/psidev/psi/ms/ValidationType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/BinaryDataArrayType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVParamType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ContactType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileChecksumType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileDescriptionType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentSoftwareRefType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/MzMLType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ObjectFactory.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupRefType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/RunType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ScanType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumDescriptionType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumListType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/UserParamType.java create mode 100644 validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/package-info.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/AcquisitionParametersFileRefObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/ExplicitAcquisitionParametersObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/InstrumentConfigurationObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/LaserWavelengthObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/MandatoryElementsObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/MassSpectraOrParameterFileInSourceFileListObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/MatrixSolutionObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/OtherSourceObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/ParameterFileInSourceFileListObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/SoftwareListObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/SpectrumObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/TemplateObjectRule.java create mode 100644 validator/src/main/java/psidev/psi/ms/object_rules/util/ObjectRuleUtil.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/MaldiOrEsiCondition.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterAgent.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterManager.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleCondition.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleConditions.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleToSkip.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryElements.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzIdentMLElement.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzMLElement.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectFactory.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleCondition.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleConditions.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleToSkip.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ReferencedRules.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/References.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RuleFilter.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RulesToSkipRef.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserCondition.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserConditions.java create mode 100644 validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserOption.java create mode 100644 validator/src/main/java/psidev/psi/ms/swingworker/SwingWorker.java create mode 100644 validator/src/main/resources/ObjectRules.xml create mode 100644 validator/src/main/resources/ObjectRulesMIAPE.xml create mode 100644 validator/src/main/resources/defaultMzMLElement.cfg.xml create mode 100644 validator/src/main/resources/log4j.properties create mode 100644 validator/src/main/resources/miape-ms-rules.xml create mode 100644 validator/src/main/resources/ms-mapping.xml create mode 100644 validator/src/main/resources/ontologies.xml create mode 100644 validator/src/main/resources/ruleFilterMIAPE.xml create mode 100644 validator/src/main/resources/validation.properties create mode 100644 validator/src/test/java/psidev/psi/ms/rulefilter/RuleFilterTest.java diff --git a/validator/pom.xml b/validator/pom.xml new file mode 100644 index 0000000..e2c5094 --- /dev/null +++ b/validator/pom.xml @@ -0,0 +1,242 @@ + + + 4.0.0 + + psidev.psi.ms + mzMLValidator + jar + 1.2-SNAPSHOT + + PSI mzML semantic validator + + A semantic validator for PSI mzML XMl files. + + + + + lib + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + + org.apache.maven.plugins + maven-dependency-plugin + 2.4 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/${lib.dir} + false + false + true + + + + + + + + + + + + + gui-app + + true + + + + + + maven-assembly-plugin + + + + psidev.psi.ms.MzMLValidatorGUI + + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + gui-assembly + + false + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + psidev.psi.ms.MzMLValidatorGUI + true + ${lib.dir} + + + + + + + + + schemaValidation + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + psidev.psi.ms.MzMLSchemaValidator + true + ${lib.dir} + + + + + + + + + commandlineValidator + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + psidev.psi.ms.MzMLValidator + true + ${lib.dir} + + + + + + + + + + + + + + + ebi-repo + The EBI internal repository + http://www.ebi.ac.uk/~maven/m2repo + + true + + + false + + + + ebi-repo-snapshots + The EBI internal repository + http://www.ebi.ac.uk/~maven/m2repo_snapshots + + false + + + true + + + + + + + psidev.psi.tools + validator + 2.0.3-SNAPSHOT + + + + uk.ac.ebi.jmzml + jmzml + 1.6.8-SNAPSHOT + + + + junit + junit + 4.9 + test + + + + net.java.dev.swing-layout + swing-layout + 1.0.2 + + + + + + + diff --git a/validator/src/main/java/psidev/psi/ms/ClusteredContext.java b/validator/src/main/java/psidev/psi/ms/ClusteredContext.java new file mode 100644 index 0000000..0e1ed34 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/ClusteredContext.java @@ -0,0 +1,44 @@ +package psidev.psi.ms; + +import java.util.ArrayList; +import java.util.List; + +import psidev.psi.tools.validator.Context; + +/** + * A context which cluster the different contexts for a same error message + * + */ +public class ClusteredContext extends Context { + + List contexts = new ArrayList(); + + public ClusteredContext(String context) { + super(context); + } + + public ClusteredContext() { + super(null); + } + + public List getContexts() { + return contexts; + } + + public int getNumberOfContexts() { + return contexts.size(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(128); + + if (!contexts.isEmpty()) { + sb.append(contexts.iterator().next()); + if (contexts.size() > 1) + sb.append(" in " + getNumberOfContexts() + " locations"); + } + + return sb.toString(); + } +} diff --git a/validator/src/main/java/psidev/psi/ms/ExtendedValidatorReport.java b/validator/src/main/java/psidev/psi/ms/ExtendedValidatorReport.java new file mode 100644 index 0000000..9297a19 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/ExtendedValidatorReport.java @@ -0,0 +1,280 @@ +package psidev.psi.ms; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; + +import psidev.psi.ms.rulefilter.RuleFilterManager; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.Rule; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import psidev.psi.tools.validator.rules.cvmapping.CvRule; +import psidev.psi.tools.validator.rules.cvmapping.MappingRuleStatus; +import psidev.psi.tools.validator.util.ValidatorReport; + +public class ExtendedValidatorReport extends ValidatorReport { + + private static final String NEW_LINE = System.getProperty("line.separator");; + HashMap objectRulesNotChecked = new HashMap(); + HashMap objectRulesValid = new HashMap(); + HashMap objectRulesInvalid = new HashMap(); + + public ExtendedValidatorReport(Collection objectRules) { + super(new ArrayList()); + this.addObjectRules(objectRules); + } + + public Collection getObjectRulesNotChecked() { + return objectRulesNotChecked.values(); + } + + public Collection getObjectRulesValid() { + return objectRulesValid.values(); + } + + public Collection getObjectRulesInvalid() { + return objectRulesInvalid.values(); + } + + public void setCvRules(Collection cvRules, RuleFilterManager filterManager) { + this.clearCvMappingRules(); + + for (CvRule rule : cvRules) { + if (rule.getStatus().compareTo(MappingRuleStatus.INVALID_XPATH) == 0) + this.getCvRulesInvalidXpath().add(rule); + else if (rule.getStatus().compareTo(MappingRuleStatus.NOT_CHECKED) == 0) + this.getCvRulesNotChecked().add(rule); + else if (rule.getStatus().compareTo(MappingRuleStatus.VALID_RULE) == 0) + this.getCvRulesValid().add(rule); + else if (rule.getStatus().compareTo(MappingRuleStatus.VALID_XPATH) == 0) + this.getCvRulesValidXpath().add(rule); + } + if (filterManager != null) { + if (!filterManager.getCvMappingRulesToSkip().isEmpty()) { + List toRemove = new ArrayList(); + // look in valid rules and in valid xpath: + for (String cvRuleId : filterManager.getCvMappingRulesToSkip()) { + for (CvRule cvRuleValid : this.getCvRulesValid()) { + if (cvRuleValid.getId().equals(cvRuleId)) + toRemove.add(cvRuleValid); + } + } + for (CvRule cvRule : toRemove) { + this.getCvRulesValid().remove(cvRule); + this.getCvRulesNotChecked().add(cvRule); + } + toRemove.clear(); + // look in valid xpath rules: + for (String cvRuleId : filterManager.getCvMappingRulesToSkip()) { + for (CvRule cvRuleValidXpath : this.getCvRulesValidXpath()) { + if (cvRuleValidXpath.getId().equals(cvRuleId)) + toRemove.add(cvRuleValidXpath); + } + } + for (CvRule cvRule : toRemove) { + this.getCvRulesValidXpath().remove(cvRule); + this.getCvRulesNotChecked().add(cvRule); + } + } + } + } + + private void addObjectRules(Collection objectRules) { + addToMap(objectRules, objectRulesNotChecked); + } + + private void clearCvMappingRules() { + this.getCvRulesInvalidXpath().clear(); + this.getCvRulesValid().clear(); + this.getCvRulesNotChecked().clear(); + this.getCvRulesValidXpath().clear(); + } + + private void clearObjectRules() { + this.objectRulesInvalid.clear(); + this.objectRulesNotChecked.clear(); + this.objectRulesValid.clear(); + } + + /** + * Update the lists of object rules depending on the result of the rule + * + * @param rule + * @param resultCheck + */ + public void objectRuleExecuted(ObjectRule rule, Collection resultCheck) { + boolean valid; + if (resultCheck == null || resultCheck.isEmpty()) + valid = true; + else + valid = false; + + // remove from the list of rules not applied + this.objectRulesNotChecked.remove(rule.getId()); + + // if valid, add to the list of valid rules + if (valid) { + if (!this.objectRulesValid.containsKey(rule.getId())) + this.objectRulesValid.put(rule.getId(), rule); + } else { + if (!this.objectRulesInvalid.containsKey(rule.getId())) + this.objectRulesInvalid.put(rule.getId(), rule); + + this.objectRulesValid.remove(rule.getId()); + } + } + + public void objectRuleExecuted(ObjectRule rule, ValidatorMessage resultCheck) { + Collection messages = new ArrayList(); + messages.add(resultCheck); + this.objectRuleExecuted(rule, messages); + } + + public void setObjectRuleAsSkipped(String ruleId) { + ObjectRule objectRule = getObjectRuleById(ruleId); + if (objectRule != null) { + // add to NotChecked rules + if (getObjectRuleById(ruleId, this.objectRulesNotChecked) == null) + this.objectRulesNotChecked.put(objectRule.getId(), objectRule); + // remove from the other collections + this.objectRulesInvalid.remove(objectRule.getId()); + this.objectRulesValid.remove(objectRule.getId()); + } + } + + private CvRule getCvRuleById(String ruleId, Collection rules) { + for (CvRule cvRule : rules) { + if (cvRule.getId().equals(ruleId)) + return cvRule; + } + return null; + } + + /** + * Search for a rule in a collection of rules + * + * @param ruleId + * @param map + * @return + */ + private ObjectRule getObjectRuleById(String ruleId, HashMap map) { + return map.get(ruleId); + } + + /** + * Search for a cvRule in all collections in the class + * + * @param ruleId + * @return + */ + private CvRule getCvRuleById(String ruleId) { + if (ruleId != null) { + for (CvRule cvRule : this.getCvRulesInvalidXpath()) { + if (ruleId.equals(cvRule.getId())) + return cvRule; + } + for (CvRule cvRule : this.getCvRulesNotChecked()) { + if (ruleId.equals(cvRule.getId())) + return cvRule; + } + for (CvRule cvRule : this.getCvRulesValid()) { + if (ruleId.equals(cvRule.getId())) + return cvRule; + } + for (CvRule cvRule : this.getCvRulesValidXpath()) { + if (ruleId.equals(cvRule.getId())) + return cvRule; + } + } + return null; + } + + /** + * Search for an object rule in all collections in the class + * + * @param ruleId + * @return + */ + private ObjectRule getObjectRuleById(String ruleId) { + if (ruleId != null) { + if (this.objectRulesInvalid.containsKey(ruleId)) + return this.objectRulesInvalid.get(ruleId); + + if (this.objectRulesNotChecked.containsKey(ruleId)) + return this.objectRulesNotChecked.get(ruleId); + + if (this.objectRulesValid.containsKey(ruleId)) + return this.objectRulesValid.get(ruleId); + } + return null; + } + + private void printCvMappingRules(StringBuilder sb, String header, Collection rules) { + sb.append(header + " (" + rules.size() + ")" + NEW_LINE); + sb.append("-----------------------------------------------------").append(NEW_LINE); + for (Rule rule : rules) { + sb.append(rule.getId()).append(" - ").append(rule.getName()).append(NEW_LINE); + } + sb.append(NEW_LINE); + } + + private void printObjectRules(StringBuilder sb, String header, Collection rules) { + sb.append(header + " (" + rules.size() + ")" + NEW_LINE); + sb.append("-----------------------------------------------------").append(NEW_LINE); + for (Rule rule : rules) { + sb.append(rule.getId()).append(" - ").append(rule.getName()).append(NEW_LINE); + } + sb.append(NEW_LINE); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + printCvMappingRules(sb, "Valid cvMapping rules", this.getCvRulesValid()); + printCvMappingRules(sb, "cvMapping Rules with valid Xpath that have not collected data", + this.getCvRulesValidXpath()); + printCvMappingRules(sb, "cvMapping Rules with invalid Xpath", this.getCvRulesInvalidXpath()); + printCvMappingRules(sb, "cvMapping Rules that haven't been run", + this.getCvRulesNotChecked()); + printObjectRules(sb, "Valid object rules", this.getObjectRulesValid()); + printObjectRules(sb, "Invalid object rules", this.getObjectRulesInvalid()); + printObjectRules(sb, "Object rules that haven't been run", this.getObjectRulesNotChecked()); + return sb.toString(); + } + + public void setObjectRuleAsInvalid(String ruleId) { + ObjectRule objectRule = getObjectRuleById(ruleId); + if (objectRule != null) { + // add to invalid rules + if (getObjectRuleById(ruleId, this.objectRulesInvalid) == null) + this.objectRulesInvalid.put(objectRule.getId(), objectRule); + // remove from the other collections + this.objectRulesNotChecked.remove(objectRule.getId()); + this.objectRulesValid.remove(objectRule.getId()); + } + } + + // UTIL + private void addToMap(ObjectRule objectRule, HashMap map) { + if (!map.containsKey(objectRule.getId())) + map.put(objectRule.getId(), objectRule); + } + + private void addToMap(Collection objectRules, HashMap map) { + for (ObjectRule objectRule : objectRules) { + this.addToMap(objectRule, map); + } + } + + public int getTotalCvRules() { + return getCvRulesInvalidXpath().size() + getCvRulesNotChecked().size() + + getCvRulesValid().size() + getCvRulesValidXpath().size(); + } + + public int getTotalObjectRules() { + return this.objectRulesInvalid.size() + this.objectRulesNotChecked.size() + + this.objectRulesValid.size(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/MzMLSchemaValidator.java b/validator/src/main/java/psidev/psi/ms/MzMLSchemaValidator.java new file mode 100644 index 0000000..1c6c3a7 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/MzMLSchemaValidator.java @@ -0,0 +1,195 @@ +/** + * Created by IntelliJ IDEA. User: martlenn Date: 14-Oct-2008 Time: 16:06:58 + */ +package psidev.psi.ms; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.Reader; +import java.net.MalformedURLException; +import java.net.URI; + +import javax.xml.transform.sax.SAXSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import psidev.psi.tools.validator.ValidatorMessage; + +/** + * This class + * + * @author martlenn + * @version $Id$ + */ +public class MzMLSchemaValidator { + + /** + * This static object is used to create the Schema object used for + * validation. + */ + private static final SchemaFactory SCHEMA_FACTORY = SchemaFactory + .newInstance("http://www.w3.org/2001/XMLSchema"); + + /** + * The schema to validate against. + */ + private Schema schema = null; + + /** + * This method carries out the work of validating the XML file passed in + * through 'inputStream' against the compiled XML schema 'schema'. This + * method is a helper method called by the implementation of this abstract + * class. + * + * @param reader + * being a java.io.Reader from the complete XML file being + * validated. + * @param schema + * being a compiled schema object built from the appropriate xsd + * ( performed by the implementing sub-class of this abstract + * class.) + * @return an XMLValidationErrorHandler that can be queried for details of + * any parsing errors to retrieve plain text or HTML + * @throws org.xml.sax.SAXException + */ + protected MzMLValidationErrorHandler validate(Reader reader, Schema schema) throws SAXException { + + final MzMLValidationErrorHandler mzMLValidationErrorHandler = new MzMLValidationErrorHandler(); + Validator validator = schema.newValidator(); + validator.setErrorHandler(mzMLValidationErrorHandler); + try { + validator.validate(new SAXSource(new InputSource(reader))); + } catch (IOException ioe) { + mzMLValidationErrorHandler.fatalError(ioe); + } catch (SAXParseException spe) { + // commented: the fatal error is internally called before to catch + // the exception + // mzMLValidationErrorHandler.fatalError(spe); + } + return mzMLValidationErrorHandler; + } + + public void setSchema(URI aSchemaUri) throws SAXException, MalformedURLException { + schema = SCHEMA_FACTORY.newSchema(aSchemaUri.toURL()); + } + + public Schema getSchema() { + return schema; + } + + /** + * This method must be implemented to create a suitable Schema object for + * the xsd file in question. + * + * @param reader + * the XML file being validated as a Stream (Reader) + * @return an XMLValidationErrorHandler that can be queried to return all of + * the error in the XML file as plain text or HTML. + */ + public MzMLValidationErrorHandler validate(Reader reader) throws SAXException { + if (schema == null) { + throw new IllegalStateException( + "You need to set a schema to validate against first! use the 'setSchema(File aSchemaFile)' method for this!"); + } + return validate(reader, schema); + } + + public static void main(String[] args) { + + MzMLSchemaValidator validator = new MzMLSchemaValidator(); + + if (args == null || args.length != 2) { + printUsage(); + System.exit(1); + } + // Check schema file. + File schemaFile = new File(args[0]); + if (!schemaFile.exists()) { + System.err.println("\nUnable to find the schema file you specified: '" + args[0] + + "'!\n"); + System.exit(1); + } + if (schemaFile.isDirectory()) { + System.err.println("\nThe schema file you specified ('" + args[0] + + "') was a folder, not a file!\n"); + System.exit(1); + } + if (!schemaFile.getName().toLowerCase().endsWith(".xsd")) { + System.err.println("Warning: your schema file does not carry the extension '.xsd'!"); + } + + // Check input folder. + File inputFolder = new File(args[1]); + if (!inputFolder.exists()) { + System.out.println("\nUnable to find the input folder you specified: '" + args[1] + + "'!\n"); + System.exit(1); + } + if (!inputFolder.isDirectory()) { + System.out.println("\nThe input folder you specified ('" + args[1] + + "') was a file, not a folder!\n"); + System.exit(1); + } + + BufferedReader br = null; + try { + // Set the schema. + validator.setSchema(schemaFile.toURI()); + System.out + .println("\nRetrieving files from '" + inputFolder.getAbsolutePath() + "'..."); + File[] inputFiles = inputFolder.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + boolean result = false; + if (name.toLowerCase().endsWith("mzml") || name.toLowerCase().endsWith("xml")) { + result = true; + } + return result; + } + }); + System.out.println("Found " + inputFiles.length + " input files.\n"); + System.out.println("Validating files..."); + for (File inputFile : inputFiles) { + System.out.println("\n\n\n - Validating file '" + inputFile.getAbsolutePath() + + "'..."); + br = new BufferedReader(new FileReader(inputFile)); + MzMLValidationErrorHandler xveh = validator.validate(br); + if (xveh.noErrors()) { + System.out.println(" File is valid!"); + } else { + System.out.println(" * Errors detected: "); + for (ValidatorMessage vMsg : xveh.getErrorsAsValidatorMessages()) { + System.out.println(vMsg.getMessage()); + } + } + br.close(); + } + System.out.println("\nAll done!\n"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (br != null) { + br.close(); + } + } catch (IOException ioe) { + // Do nothing. + } + } + } + + private static void printUsage() { + StringBuffer out = new StringBuffer(); + out.append("\n\nUsage: java ").append(MzMLSchemaValidator.class.getName()); + out.append(" "); + System.out.println(out.toString()); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/MzMLValidationErrorHandler.java b/validator/src/main/java/psidev/psi/ms/MzMLValidationErrorHandler.java new file mode 100644 index 0000000..52483ad --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/MzMLValidationErrorHandler.java @@ -0,0 +1,164 @@ +package psidev.psi.ms; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorMessage; + +/** + * @author Florian Reisinger Date: 17-Mar-2009 + * @since 1.0 + */ +public class MzMLValidationErrorHandler implements ErrorHandler { + + public MzMLValidationErrorHandler() { + super(); + errorMessages = new ArrayList(); + } + + List errorMessages = null; + + public boolean noErrors() { + return errorMessages.size() == 0; + } + + public List getErrorsAsValidatorMessages() { + return errorMessages; + } + + /** + * Receive notification of a recoverable error. + *

+ *

+ * This corresponds to the definition of "error" in section 1.2 of the W3C + * XML 1.0 Recommendation. For example, a validating parser would use this + * callback to report the violation of a validity constraint. The default + * behaviour is to take no action. + *

+ *

+ *

+ * The SAX parser must continue to provide normal parsing events after + * invoking this method: it should still be possible for the application to + * process the document through to the end. If the application cannot do so, + * then the parser should report a fatal error even if the XML 1.0 + * recommendation does not require it to do so. + *

+ *

+ *

+ * Filters may use this method to report other, non-XML errors as well. + *

+ * + * @param exception + * The error information encapsulated in a SAX parse exception. + * @throws org.xml.sax.SAXException + * Any SAX exception, possibly wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public void error(SAXParseException exception) throws SAXException { + StringBuilder sb = new StringBuilder(); + sb.append("Non-fatal XML Parsing error detected on line ") + .append(exception.getLineNumber()).append("\n Error message: ") + .append(exception.getMessage()); + errorMessages.add(new ValidatorMessage(sb.toString(), MessageLevel.ERROR)); + } + + /** + * Receive notification of a non-recoverable error. + *

+ *

+ * This corresponds to the definition of "fatal error" in section 1.2 of the + * W3C XML 1.0 Recommendation. For example, a parser would use this callback + * to report the violation of a well-formedness constraint. + *

+ *

+ *

+ * The application must assume that the document is unusable after the + * parser has invoked this method, and should continue (if at all) only for + * the sake of collecting addition error messages: in fact, SAX parsers are + * free to stop reporting any other events once this method has been + * invoked. + *

+ * + * @param exception + * The error information encapsulated in a SAX parse exception. + * @throws org.xml.sax.SAXException + * Any SAX exception, possibly wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public void fatalError(SAXParseException exception) throws SAXException { + StringBuilder sb = new StringBuilder(); + sb.append("FATAL XML Parsing error detected on line ").append(exception.getLineNumber()) + .append("\n Fatal Error message: ").append(exception.getMessage()); + errorMessages.add(new ValidatorMessage(sb.toString(), MessageLevel.FATAL)); + } + + /** + * This is a extension method to the #fatalError(SAXParseException) method + * to allow the handling of IOExceptions. Example: An FileNotFoundException + * is thrown by the validate method if the file to be validated contains a + * local reference to a DTD (which can not be found on the server). + * + * @param exception + * the IOException that this handler is supposed to handle. + */ + public void fatalError(IOException exception) { + StringBuilder sb = new StringBuilder(); + sb.append("FATAL XML Validation error. "); + if (exception instanceof FileNotFoundException) { + String exceptionMsg = exception.getMessage(); + // we are only interested in the file name that is referenced not + // the full path + // (since the full path contains the local part not necessary only + // the path specified in the XML) + String sub = exceptionMsg.substring(exceptionMsg.lastIndexOf(File.separatorChar) + 1); + sb.append("A needed or referenced File was not found!\n") + .append(" ") + .append(sub) + .append("\n Hint: Please make sure your file does not reference local schema or DTD files."); + } else { + sb.append("An I/O error prevented the file from being validated!\n"); + } + errorMessages.add(new ValidatorMessage(sb.toString(), MessageLevel.FATAL)); + } + + /** + * Receive notification of a warning. + *

+ *

+ * SAX parsers will use this method to report conditions that are not errors + * or fatal errors as defined by the XML 1.0 recommendation. The default + * behaviour is to take no action. + *

+ *

+ *

+ * The SAX parser must continue to provide normal parsing events after + * invoking this method: it should still be possible for the application to + * process the document through to the end. + *

+ *

+ *

+ * Filters may use this method to report other, non-XML warnings as well. + *

+ * + * @param exception + * The warning information encapsulated in a SAX parse exception. + * @throws org.xml.sax.SAXException + * Any SAX exception, possibly wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public void warning(SAXParseException exception) throws SAXException { + StringBuilder sb = new StringBuilder(); + sb.append("Warning: Validation of the XMl has detected the following condition on line ") + .append(exception.getLineNumber()).append("\n Warning message: ") + .append(exception.getMessage()); + errorMessages.add(new ValidatorMessage(sb.toString(), MessageLevel.WARN)); + } +} \ No newline at end of file diff --git a/validator/src/main/java/psidev/psi/ms/MzMLValidator.java b/validator/src/main/java/psidev/psi/ms/MzMLValidator.java new file mode 100644 index 0000000..c5ec244 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/MzMLValidator.java @@ -0,0 +1,1245 @@ +/** + * Created by IntelliJ IDEA. User: martlenn Date: 15-Aug-2007 Time: 15:29:31 + */ +package psidev.psi.ms; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.xml.sax.SAXException; + +import psidev.psi.ms.object_rules.MandatoryElementsObjectRule; +import psidev.psi.ms.rulefilter.RuleFilterManager; +import psidev.psi.tools.cvrReader.CvRuleReaderException; +import psidev.psi.tools.ontology_manager.impl.local.OntologyLoaderException; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.Validator; +import psidev.psi.tools.validator.ValidatorCvContext; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.Rule; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import psidev.psi.tools.validator.rules.cvmapping.CvRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.Chromatogram; +import uk.ac.ebi.jmzml.model.mzml.DataProcessingList; +import uk.ac.ebi.jmzml.model.mzml.FileDescription; +import uk.ac.ebi.jmzml.model.mzml.InstrumentConfiguration; +import uk.ac.ebi.jmzml.model.mzml.InstrumentConfigurationList; +import uk.ac.ebi.jmzml.model.mzml.MzMLObject; +import uk.ac.ebi.jmzml.model.mzml.SampleList; +import uk.ac.ebi.jmzml.model.mzml.ScanSettings; +import uk.ac.ebi.jmzml.model.mzml.Software; +import uk.ac.ebi.jmzml.model.mzml.SoftwareList; +import uk.ac.ebi.jmzml.model.mzml.SourceComponent; +import uk.ac.ebi.jmzml.model.mzml.SourceFileList; +import uk.ac.ebi.jmzml.model.mzml.Spectrum; +import uk.ac.ebi.jmzml.xml.io.MzMLObjectIterator; +import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; + +/** + * This class represents the PSI mzML semantic validator. + * + * @author Lennart Martens, modified by Juan Antonio Vizcaino and Salvador + * Martínez + * @version $Id$ + */ +public class MzMLValidator extends Validator { + // 10 steps: schema validation, reading cv-rules, fileDescription, + // sampleList, instrumentConfigurationList, scanSettingsList, + // software, + // dataProcessingList, chromatogram, spectrum, complete + private static final int PROGRESS_STEPS = 16; + // private MzMLValidatorGUI gui = null; + private MzMLValidatorGUI gui = null; + private int progress = 0; + private MessageLevel msgL = MessageLevel.WARN; + private MzMLUnmarshaller unmarshaller = null; + private HashMap> msgs; + private RuleFilterManager ruleFilterManager; + private URI schemaUri = null; + private boolean skipValidation = false; + private ExtendedValidatorReport extendedReport; + /** + * counter used for creating unique IDs. + *

+ * These are used to create temp files. + */ + private long uniqId = 0; + + /** + * Constructor to initialise the validator with the custom ontology and + * cv-mapping without object rule settings. Note: this constructor will try + * to load a local mzIdentML XML schema for syntactic schema validation. + * + * @param aOntologyConfig + * the ontology configuration file. + * @param aCvMappingFile + * the cv-mapping rule configuration file. + * @param aCodedRuleFile + * the object rule configuration file + * @param validatorGUI + * the GUI + * @throws ValidatorException + * in case the validator encounters unexpected errors. + * @throws OntologyLoaderException + * in case of problems while loading the needed ontologies. + * @throws FileNotFoundException + * in case of any configuration file doesn't exist. + * @throws CvRuleReaderException + * in case of problems while reading cv mapping rules. + * + */ + public MzMLValidator(InputStream aOntologyConfig, String aCvMappingFile, String aCodedRuleFile, + MzMLValidatorGUI validatorGUI) throws ValidatorException, OntologyLoaderException, + FileNotFoundException, CvRuleReaderException { + super(aOntologyConfig); + + InputStream cvMappingFile = null; + if(new File(aCvMappingFile).exists()) { + cvMappingFile = new FileInputStream(aCvMappingFile); + }else{ + cvMappingFile = MzMLValidator.class.getResourceAsStream("/"+aCvMappingFile); + } + InputStream objectRuleFile = null; + if(new File(aCodedRuleFile).exists()) { + objectRuleFile = new FileInputStream(aCodedRuleFile); + }else{ + objectRuleFile = MzMLValidator.class.getResourceAsStream("/"+aCodedRuleFile); + } + this.setObjectRules(objectRuleFile); + this.setCvMappingRules(cvMappingFile); + try { + cvMappingFile.close(); + objectRuleFile.close(); + } catch (IOException e1) { + // do nothing + e1.printStackTrace(); + } + + // set the gui + this.setValidatorGUI(validatorGUI); + + this.msgs = new HashMap>(); + try { + // ToDo: find better default value: e.g. official address or local + // file + this.schemaUri = new URI( + "http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/schema/mzML1.1.0_idx.xsd"); + } catch (URISyntaxException e) { + throw new IllegalStateException("Could not create URI for schema location!", e); + } + + } + + /** + * + * @param validatroGUI + * MzMLValidatorGUI that acts as the GUI parent of this + * validator. Can be 'null' if ran from the command-line. + */ + public void setValidatorGUI(MzMLValidatorGUI validatroGUI) { + this.gui = validatroGUI; + this.progress = 0; + } + + /** + * + * @param level + * MessageLevel with the minimal messagelevel to report. + */ + public void setMessageReportLevel(MessageLevel level) { + this.msgL = level; + } + + /** + * Get the currently specified schema URI instance files are validated + * against. + * + * @return the URI pointing to the mzML schema. + */ + public URI getSchemaUri() { + return schemaUri; + } + + /** + * Use this to overwrite default schema location and specify your own schema + * to validate against. Note: to be able to validate both indexed and + * non-indexed mzML files, the schema for the indexed mzML should be given. + * + * @param schemaUri + * the URI that points to the schema. + */ + public void setSchemaUri(URI schemaUri) { + this.schemaUri = schemaUri; + } + + /** + * Flag to skip the schema validation step. + * + * @return true if the schema validaton skep will be skipped with the + * current settings, false if a schema validation will be performed. + */ + public boolean isSkipValidation() { + return skipValidation; + } + + /** + * Flag to specify if a schema validation is to be performed. + * + * @param skipValidation + * set to true if the schema validation step should be skipped. + */ + public void setSkipValidation(boolean skipValidation) { + this.skipValidation = skipValidation; + } + + /** + * Validate an input stream + * + * @param aInputStream + * @return + * @throws ValidatorException + */ + public Collection validate(InputStream aInputStream) + throws ValidatorException { + + File tempFile; + try { + tempFile = storeAsTemporaryFile(aInputStream); + return this.startValidation(tempFile); + } catch (Exception e) { + e.printStackTrace(); + throw new ValidatorException("Unable to process input stream", e); + } + + } + + /** + * Store the content of the given input stream into a temporary file and + * return its descriptor. + * + * @param is + * the input stream to store. + * @return a File descriptor describing a temporary file storing the content + * of the given input stream. + * @throws IOException + * if an IO error occur. + */ + private File storeAsTemporaryFile(InputStream is) throws IOException { + + if (is == null) { + throw new IllegalArgumentException("You must give a non null InputStream"); + } + + BufferedReader in = new BufferedReader(new InputStreamReader(is)); + + // Create a temp file and write URL content in it. + File tempDirectory = new File(System.getProperty("java.io.tmpdir", "tmp")); + if (!tempDirectory.exists()) { + if (!tempDirectory.mkdirs()) { + throw new IOException("Cannot create temp directory: " + + tempDirectory.getAbsolutePath()); + } + } + + long id = getUniqueId(); + + File tempFile = File.createTempFile("validator." + id, ".xml", tempDirectory); + + log.info("The file is temporary store as: " + tempFile.getAbsolutePath()); + + BufferedWriter out = new BufferedWriter(new FileWriter(tempFile)); + + String line; + while ((line = in.readLine()) != null) { + out.write(line); + } + + in.close(); + + out.flush(); + out.close(); + + return tempFile; + } + + /** + * Return a unique ID. + * + * @return a unique id. + */ + synchronized private long getUniqueId() { + return ++uniqId; + } + + @Override + public Collection validate(Object objectToCheck) throws ValidatorException { + Collection messages = new ArrayList(); + for (ObjectRule rule : this.getObjectRules()) { + if (rule.canCheck(objectToCheck)) { + + final Collection resultCheck = rule.check(objectToCheck); + // update the object rule report + extendedReport.objectRuleExecuted(rule, resultCheck); + + if (ruleFilterManager != null) { + // state if the rule is valid in the file or not + boolean valid = true; + if (resultCheck != null && !resultCheck.isEmpty()) { + valid = false; + } + ruleFilterManager.updateRulesToSkipByObjectRuleResult(rule, valid); + } + messages.addAll(resultCheck); + } + } + return messages; + } + + /** + * The entry point of the application. + * + * @param args + * Start-up arguments; five here: the ontology configuration + * file, the CV mapping file, the coded rules file, the rule + * filter file, the mzML file to validate, and the level of the + * error messages. + */ + public static void main(String[] args) { + if (args == null || args.length != 6) { + printUsage(); + } + // Validate existence of input files. + File ontology = new File(args[0]); + if (!ontology.exists()) { + printError("The ontology config file you specified '" + args[0] + "' does not exist!"); + } else if (ontology.isDirectory()) { + printError("The ontology config file you specified '" + args[0] + + "' is a folder, not a file!"); + } + + File cvMapping = new File(args[1]); + if (!cvMapping.exists()) { + printError("The CV mapping config file you specified '" + args[1] + "' does not exist!"); + } else if (cvMapping.isDirectory()) { + printError("The CV mapping config file you specified '" + args[1] + + "' is a folder, not a file!"); + } + + File objectRules = new File(args[2]); + if (!objectRules.exists()) { + printError("The object rules config file you specified '" + args[2] + + "' does not exist!"); + } else if (objectRules.isDirectory()) { + printError("The object rules config file you specified '" + args[2] + + "' is a folder, not a file!"); + } + + // Validate rule filter file to test + File ruleFilterXMLFile = new File(args[3]); + if (!ruleFilterXMLFile.exists()) { + printError("The rule filter file you specified '" + args[3] + "' does not exist!"); + } else if (ruleFilterXMLFile.isDirectory()) { + printError("The rule filter file you specified '" + args[3] + + "' is a folder, not a file!"); + } + + // Validate file to test + File mzML = new File(args[4]); + if (!mzML.exists()) { + printError("The mzML file you specified '" + args[4] + "' does not exist!"); + } else if (mzML.isDirectory()) { + printError("The mzML file you specified '" + args[4] + "' is a folder, not a file!"); + } + + // Validate messagelevel. + MessageLevel msgLevel = getMessageLevel(args[5]); + if (msgLevel == null) { + System.err.println("\n\n *** Unknown message level '" + args[5] + "' ***\n"); + System.err.println("\tTry one of the following:"); + System.err.println("\t\t - DEBUG"); + System.err.println("\t\t - INFO"); + System.err.println("\t\t - WARN"); + System.err.println("\t\t - ERROR"); + System.err.println("\t\t - FATAL"); + System.err.println(" !!! Defaulting to 'INFO' !!!\n\n"); + msgLevel = MessageLevel.INFO; + + } + + // OK, all validated. Let's get going! + Collection messages = new ArrayList(); + // We create the validator here: + MzMLValidator validator = null; + + try { + InputStream ontInput = new FileInputStream(ontology); + // rule filter manager + RuleFilterManager ruleFilterManager = null; + if (ruleFilterXMLFile != null) + ruleFilterManager = new RuleFilterManager(ruleFilterXMLFile); + validator = new MzMLValidator(ontInput, cvMapping.getAbsolutePath(), + objectRules.getAbsolutePath(), null); + validator.setMessageReportLevel(msgLevel); + validator.setRuleFilterManager(ruleFilterManager); + + // Add the messages to the ArrayList messages and use the + // startValidation() method (below). + messages.addAll(validator.startValidation(mzML)); + } catch (Exception e) { + System.err.println("\n\nException occurred: " + e.getMessage()); + e.printStackTrace(); + } + + // ---------------- Print messages ---------------- // + System.out.println(validator.printMessages(messages)); + System.out.println("\n"); + System.out.println(validator.printValidatorReport()); + System.out.println("\n"); + System.out.println(validator.printCvContextReport()); + System.out.println("\n\nAll done. Goodbye."); + } + + /** + * Sets the ruleFilterManager + * + * @param ruleFilterManager + */ + public void setRuleFilterManager(RuleFilterManager ruleFilterManager) { + this.ruleFilterManager = ruleFilterManager; + } + + public String printValidatorReport() { + ExtendedValidatorReport report = this.getExtendedReport(); + if (report != null) { + if (report.getTotalCvRules() == 0) + report.setCvRules(getCvRuleManager().getCvRules(), this.ruleFilterManager); + + int cvRulesTotal = report.getTotalCvRules(); + int objectRulesTotal = report.getTotalObjectRules(); + + StringBuilder sb = new StringBuilder(); + sb.append("\n\n\n---------- ---------- Rule statistics ---------- ----------\n\n"); + + sb.append("\tCvMappingRule total count: ").append(cvRulesTotal).append("\n"); + sb.append("\tCvMappingRules not run: ").append(report.getCvRulesNotChecked().size()) + .append("\n"); + for (CvRule rule : report.getCvRulesNotChecked()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tCvMappingRules with invalid Xpath: ") + .append(report.getCvRulesInvalidXpath().size()).append("\n"); + for (CvRule rule : report.getCvRulesInvalidXpath()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tCvMappingRules valid Xpath, but no hit: ") + .append(report.getCvRulesValidXpath().size()).append("\n"); + for (CvRule rule : report.getCvRulesValidXpath()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tCvMappingRules run & valid: ").append(report.getCvRulesValid().size()) + .append("\n"); + for (CvRule rule : report.getCvRulesValid()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tObjectRule total count: ").append(objectRulesTotal).append("\n"); + sb.append("\tObjectRules not run: ").append(report.getObjectRulesNotChecked().size()) + .append("\n"); + for (ObjectRule rule : report.getObjectRulesNotChecked()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tObjectRules run & invalid: ") + .append(report.getObjectRulesInvalid().size()).append("\n"); + for (ObjectRule rule : report.getObjectRulesInvalid()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("\tObjectRules run & valid: ").append(report.getObjectRulesValid().size()) + .append("\n"); + for (ObjectRule rule : report.getObjectRulesValid()) { + sb.append("\t\trule: ").append(rule.getId()).append("\n"); + } + sb.append("---------- ---------- ---------- ---------- ----------\n"); + + return sb.toString(); + } + return ""; + } + + public String printCvContextReport() { + StringBuilder sb = new StringBuilder(); + + if (ValidatorCvContext.getInstance() != null + && !ValidatorCvContext.getInstance().getNotRecognisedXpath().isEmpty()) { + sb.append("\n\n\n---------- ---------- CvContext statistics ---------- ----------\n\n"); + // check for terms that were not anticipated with the rules in the + // CV mapping file. + for (String xpath : ValidatorCvContext.getInstance().getNotRecognisedXpath()) { + sb.append("\t").append(xpath).append("\n"); + sb.append("\tunrecognized terms:\n"); + for (String term : ValidatorCvContext.getInstance().getNotRecognisedTerms(xpath)) { + sb.append(term).append("; "); + } + } + } + + return sb.toString(); + } + + /** + * Starts the validation of a mzML file + * + * @param mzMLFile + * File with the mzML file to validate. + * @return Collection with validator messages. + */ + public Collection startValidation(File mzMLFile) { + // reset old validation results + // this will currently reset the status of all CvRules to a "not run" + // status + super.resetCvRuleStatus(); + // set the extended validator + this.extendedReport = new ExtendedValidatorReport(getObjectRules()); + + // init gui + if (this.gui != null) { + progress = 0; + this.gui.initProgress(progress, PROGRESS_STEPS, progress); + } + + // first up we check if the file is actually valid against the schema + // (if not disabled) + String guiProgressNote; + if (skipValidation) { + guiProgressNote = "Skipping schema validation!"; + if (this.gui != null) { + this.gui.setProgress(++progress, guiProgressNote); + try { + // sleep for a second to give the user time to see this + // important message + Thread.sleep(1000); + } catch (InterruptedException e) { + // if we are interrupted (which should not happen) we just + // go + // on. + } + } else { + System.out.println(guiProgressNote); + } + + } else { // validating + guiProgressNote = "Validating against schema (depending on the file size, this might take a while)..."; + if (this.gui != null) { + this.gui.setProgress(++progress, guiProgressNote); + } else { + System.out.println(guiProgressNote); + } + + boolean valid; + try { + valid = isValidMzML(mzMLFile, schemaUri); + } catch (SAXException e) { + log.error("ERROR during schema validation.", e); + final ValidatorMessage message = new ValidatorMessage( + "ERROR during schema validation." + e.getMessage(), MessageLevel.ERROR); + addValidatorMessage("schema validation", message, this.msgL); + valid = false; + } + + // handle schema validation failure + if (!valid) { + if (this.gui != null) { + return clusterByMessagesAndRules(getMessageCollection()); + + } else { + System.err.println("The provided file is not valid against the mzML schema!"); + System.err.println("Input file : " + mzMLFile.getAbsolutePath()); + System.err.println("Schema location: " + schemaUri); + for (ValidatorMessage msg : getMessageCollection()) { + System.err.println(msg.getMessage()); + } + System.exit(-1); + } + } + + } + try { + // We create an MzMLUnmarshaller (this specialised Unmarshaller will + // internally use a XML index + // to marshal the mzML file in snippets given by their Xpath) + this.unmarshaller = new MzMLUnmarshaller(mzMLFile.toURI().toURL(), false); + + // ---------------- Internal consistency check of the CvMappingRules + // ---------------- // + + // Validate CV Mapping Rules + if (this.gui != null) { // report progress to the GUI if present + this.gui.setProgress(++progress, "Checking internal consistency of CV rules......"); + } + + addMessages(this.checkCvMappingRules(), this.msgL); + // See if the mapping makes sense. + if (this.msgs.size() != 0) { + if (this.gui == null) { + System.err + .println("\n\nThere were errors processing the CV mapping configuration file:\n"); + for (ValidatorMessage lMessage : getMessageCollection()) { + System.err.println("\t - " + lMessage); + } + System.err.println("\n\n"); + printError("Unable to start validation due to configuration errors.\nSee above."); + } else { + return getMessageCollection(); + } + } + + // ---------------- Validation work proper ---------------- // + + // Object rules that check internal Xrefs (e.g.: + // referenceableParamGroups and refs). + // Failure = auto-exit. + // @TODO Check internal references with object rules! + // **************************** + // CHECK MANDATORY ELEMENTS + // **************************** + checkMandatoryElements(); + + // **************************** + // OBJECT RULES + // **************************** + applyObjectRules(); + + // If we get here, the document is validatable. So proceed with the + // CV mapping rules. + applyCVMappingRules(); + + if (this.gui != null) { + this.gui.setProgress(++progress, "Validation complete, compiling output..."); + } + } catch (Exception e) { + if (this.gui == null) { + System.err.println("\n\nException occurred: " + e.getMessage()); + e.printStackTrace(); + } else { + this.gui.notifyOfError(e); + return new ArrayList(); + } + } + + // If ruleFilterManager is enabled, filter the messages. + // Anyway, cluster the messages + if (ruleFilterManager != null) { + final Collection filteredValidatorMessages = ruleFilterManager + .filterValidatorMessages(this.msgs, this.extendedReport); + final Collection clusteredMessages = this + .clusterByMessagesAndRules(filteredValidatorMessages); + return clusteredMessages; + } else { + // or return all messages for semantic validation + final Collection clusteredMessages = this + .clusterByMessagesAndRules(this.getMessageCollection()); + return clusteredMessages; + } + } + + /** + * Clusters the ValidatorMessages + * + * @param messages + * @return + */ + private Collection clusterByMessagesAndRules( + Collection messages) { + Collection clusteredMessages = new ArrayList( + messages.size()); + + // build a first clustering by message and rule + Map>> clustering = new HashMap>>(); + for (ValidatorMessage message : messages) { + // if the message doen't have an associated rule, store it directly + // (comes from schema validation) + if (message.getRule() == null) + clusteredMessages.add(message); + else { + // if contains the same message, from the same rule, cluster it + if (clustering.containsKey(message.getMessage())) { + Map> messagesCluster = clustering.get(message + .getMessage()); + + if (messagesCluster.containsKey(message.getRule())) { + messagesCluster.get(message.getRule()).add(message); + } else { + Set validatorMessages = new HashSet(); + validatorMessages.add(message); + messagesCluster.put(message.getRule(), validatorMessages); + } + } else { + Map> messagesCluster = new HashMap>(); + + Set validatorMessages = new HashSet(); + validatorMessages.add(message); + messagesCluster.put(message.getRule(), validatorMessages); + + clustering.put(message.getMessage(), messagesCluster); + } + } + } + + // build a second cluster by message level + Map clusteringByMessageLevel = new HashMap(); + + for (Map.Entry>> entry : clustering.entrySet()) { + + String message = entry.getKey(); + Map> ruleCluster = entry.getValue(); + + // cluster by message level and create proper validatorMessage + for (Map.Entry> ruleEntry : ruleCluster.entrySet()) { + clusteringByMessageLevel.clear(); + + Rule rule = ruleEntry.getKey(); + Set validatorMessages = ruleEntry.getValue(); + + for (ValidatorMessage validatorMessage : validatorMessages) { + + if (clusteringByMessageLevel.containsKey(validatorMessage.getLevel())) { + ClusteredContext clusteredContext = clusteringByMessageLevel + .get(validatorMessage.getLevel()); + + clusteredContext.getContexts().add(validatorMessage.getContext()); + } else { + ClusteredContext clusteredContext = new ClusteredContext(); + + clusteredContext.getContexts().add(validatorMessage.getContext()); + + clusteringByMessageLevel.put(validatorMessage.getLevel(), clusteredContext); + } + } + + for (Map.Entry levelEntry : clusteringByMessageLevel + .entrySet()) { + + ValidatorMessage validatorMessage = new ValidatorMessage(message, + levelEntry.getKey(), levelEntry.getValue(), rule); + clusteredMessages.add(validatorMessage); + + } + } + } + + return clusteredMessages; + } + + /** + * Check for the presence of all mandatory elements required at this + * validation type + */ + private void checkMandatoryElements() { + List ret = new ArrayList(); + if (ruleFilterManager != null) { + final List mandatoryElements = ruleFilterManager.getMandatoryElements(); + for (String elementName : mandatoryElements) { + MzMLElement mzMLElement = getMzMLElement(elementName); + // check if that element is present on the file + final MzMLObject mzIdentMLObject = unmarshaller.unmarshalFromXpath( + mzMLElement.getXpath(), mzMLElement.getClazz()); + if (mzIdentMLObject == null) { + final MandatoryElementsObjectRule mandatoryObjectRule = new MandatoryElementsObjectRule( + ontologyMngr); + final ValidatorMessage validatorMessage = new ValidatorMessage( + "The element on xPath:'" + mzMLElement.getXpath() + + "' is required for the current type of validation.", + MessageLevel.ERROR, new Context(mzMLElement.getXpath()), + mandatoryObjectRule); + // extendedReport.objectRuleExecuted(mandatoryObjectRule, + // validatorMessage); + // this.addObjectRule(mandatoryObjectRule); + addValidatorMessage(validatorMessage.getRule().getId(), validatorMessage, + this.msgL); + } + } + } + } + + private MzMLElement getMzMLElement(String elementName) { + for (MzMLElement element : MzMLElement.values()) { + if (element.name().equals(elementName)) + return element; + } + return null; + } + + + private Collection getMessageCollection() { + Collection ret = new HashSet(); + for (String key : this.msgs.keySet()) { + final List list = this.msgs.get(key); + if (list != null) { + ret.addAll(list); + } + } + return ret; + } + + private void applyCVMappingRules() throws ValidatorException { + // -------------------- + // Validate the file description. + // -------------------- // + // ToDo: check: if there is only one such element in the XML, we can + // use the unmarshalFromXpath() method! + // This is the new way to do it (not considering the unmarshaller) + checkElementCvMapping(MzMLElement.FileDescription.getXpath(), FileDescription.class); + + // -------------------- + // Validate the sample list. + // -------------------- // + checkElementCvMapping(MzMLElement.SampleList.getXpath(), SampleList.class); + + // -------------------- + // Validate the software list. + // -------------------- // + checkElementCvMapping(MzMLElement.Software.getXpath(), Software.class); + + // -------------------- + // Validate the instrument configuration list + // (substituting the former instrument list) + // -------------------- // + checkElementCvMapping(MzMLElement.InstrumentConfigurationList.getXpath(), + InstrumentConfigurationList.class); + + // -------------------- + // Validate the data processing list. + // -------------------- // + checkElementCvMapping(MzMLElement.DataProcessingList.getXpath(), DataProcessingList.class); + + // -------------------- + // Validate the chromatogram binary data array. + // -------------------- // + checkElementCvMapping(MzMLElement.Chromatogram.getXpath(), Chromatogram.class); + + // -------------------- + // Validate each spectrum (in parallel depending of CPU cores) + // -------------------- // + + if (this.gui != null) { + this.gui.setProgress(++progress, "Validating " + MzMLElement.Spectrum.getXpath() + + " (this might take a while)..."); + } + // iterator to provide MzMLObjects + MzMLObjectIterator spectrumIterator = this.unmarshaller.unmarshalCollectionFromXpath( + MzMLElement.Spectrum.getXpath(), Spectrum.class); + + // create synchronized List to which all threads can write their + // Validator messages + Map> sync_msgs = Collections + .synchronizedMap(new HashMap>()); + + // Create lock. + InnerLock lock = new InnerLock(); + InnerIteratorSync iteratorSync = new InnerIteratorSync(spectrumIterator); + Collection runners = new ArrayList(); + int processorCount = Runtime.getRuntime().availableProcessors(); + for (int i = 0; i < processorCount; i++) { + InnerSpecValidator runner = new InnerSpecValidator(iteratorSync, lock, i); + runners.add(runner); + new Thread(runner).start(); + } + + // Wait for it. + lock.isDone(runners.size()); + // now we add all the collected messages from the spectra validators + // to the general message list + addSyncMessages(sync_msgs, this.msgL); + } + + /** + * Apply object rules + * + * @return a collection of {@link ValidatorMessage} + * @throws ValidatorException + */ + private void applyObjectRules() throws ValidatorException { + + // instrumentConfiguration + checkElementObjectRule(MzMLElement.InstrumentConfiguration.getXpath(), + InstrumentConfiguration.class); + + // source file list + checkElementObjectRule(MzMLElement.SourceFileList.getXpath(), SourceFileList.class); + + // source + checkElementObjectRule(MzMLElement.SourceComponent.getXpath(), SourceComponent.class); + + // softwareList + checkElementObjectRule(MzMLElement.SoftwareList.getXpath(), SoftwareList.class); + + // scan settings + checkElementObjectRule(MzMLElement.ScanSettings.getXpath(), ScanSettings.class); + + } + + private void checkElementCvMapping(String xpath, Class clazz) throws ValidatorException { + MzMLObjectIterator mzMLIter; + if (this.gui != null) { + this.gui.setProgress(++progress, "Validating " + xpath + "..."); + } + mzMLIter = this.unmarshaller.unmarshalCollectionFromXpath(xpath, clazz); + + Collection toValidate = new ArrayList(); + while (mzMLIter.hasNext()) { + final Object next = mzMLIter.next(); + toValidate.add(next); + } + + final Collection cvMappingResult = this.checkCvMapping(toValidate, xpath); + + addMessages(cvMappingResult, this.msgL); + } + + private void checkElementObjectRule(String xpath, Class clazz) throws ValidatorException { + MzMLObjectIterator mzMLIter; + if (this.gui != null) { + this.gui.setProgress(++progress, "Validating " + xpath + "..."); + } + mzMLIter = this.unmarshaller.unmarshalCollectionFromXpath(xpath, clazz); + + Collection objectRuleResult = new ArrayList(); + Collection toValidate = new ArrayList(); + while (mzMLIter.hasNext()) { + final MzMLObject next = mzMLIter.next(); + final Collection validationResult = this.validate(next); + if (validationResult != null && !validationResult.isEmpty()) + objectRuleResult.addAll(validationResult); + } + + addMessages(objectRuleResult, this.msgL); + } + + @Override + public Collection checkCvMapping(Collection collection, String xPath) + throws ValidatorException { + Collection messages = new ArrayList(); + + if (this.getCvRuleManager() != null) { + for (CvRule rule : this.getCvRuleManager().getCvRules()) { + for (Object o : collection) { + if (rule.canCheck(xPath)) { + final Collection resultCheck = rule.check(o, xPath); + if (this.ruleFilterManager != null) { + // state if the rule is valid in the file or not + boolean valid = true; + if (resultCheck != null && !resultCheck.isEmpty()) { + valid = false; + } + this.ruleFilterManager.updateRulesToSkipByCvMappingRuleResult(rule, + valid); + } + messages.addAll(resultCheck); + } + } + } + } else { + log.error("The CvRuleManager has not been set up yet."); + } + return messages; + } + + private void addValidatorMessage(String ruleId, ValidatorMessage validatorMessage, + MessageLevel msgLevel) { + + if (validatorMessage.getLevel().isHigher(msgLevel) + || validatorMessage.getLevel().isSame(msgLevel)) { + if (this.msgs.containsKey(ruleId)) { + this.msgs.get(ruleId).add(validatorMessage); + } else { + List list = new ArrayList(); + list.add(validatorMessage); + this.msgs.put(ruleId, list); + } + this.extendedReport.setObjectRuleAsInvalid(ruleId); + } else { + this.extendedReport.setObjectRuleAsSkipped(ruleId); + } + } + + /** + * Add a new object rule to the list of object rules only if it is not + * already in the list + * + * @param rule + * @return true if has been added or false if not + */ + private boolean addObjectRule(ObjectRule rule) { + boolean isNew = true; + for (ObjectRule objectRule : this.getObjectRules()) { + if (objectRule.getId().equals(rule.getId())) + isNew = false; + } + if (isNew) + this.getObjectRules().add(rule); + return isNew; + } + + private boolean isValidMzML(File mzML, URI schemaUri) throws SAXException { + boolean valid; + + MzMLSchemaValidator mzMLschemaValidator = new MzMLSchemaValidator(); + MzMLValidationErrorHandler errorHandler = null; + try { + mzMLschemaValidator.setSchema(schemaUri); + errorHandler = mzMLschemaValidator.validate(new FileReader(mzML)); + } catch (FileNotFoundException e) { + log.fatal("FATAL: Could not find the MzML instance file while trying to " + + "validate it! Its existence should have been checked before!", e); + System.exit(-1); + } catch (MalformedURLException e) { + log.fatal("FATAL: The MzML schema URI is not "); + // should not happen! since the MzMLValidator should check first if + // the + // schema URI is valid before trying to validate with it! + e.printStackTrace(); + System.exit(-1); + } + + // if we have no errors, the file is valid + if (errorHandler.noErrors()) { + valid = true; + } else { + for (ValidatorMessage validatorMessage : errorHandler.getErrorsAsValidatorMessages()) { + addValidatorMessage("schema validation", validatorMessage, this.msgL); + } + valid = false; + } + + return valid; + } + + /** + * Simple wrapper class to allow synchronisation on the hasNext() and next() + * methods of the iterator. + */ + private class InnerIteratorSync { + private Iterator iter = null; + + public InnerIteratorSync(Iterator aIterator) { + iter = aIterator; + } + + public synchronized T next() { + T result = null; + if (iter.hasNext()) { + result = iter.next(); + } + return result; + } + } + + /** + * Simple lock class so the main thread can detect worker threads' + * completion. + */ + private class InnerLock { + private int doneCount = 0; + + public synchronized void updateDoneCount() { + doneCount++; + notifyAll(); + } + + public synchronized boolean isDone(int totalCount) { + while (doneCount < totalCount) { + try { + wait(); + } catch (InterruptedException ie) { + System.err.println("I've been interrupted..."); + } + } + return true; + } + } + + /** + * Runnable that requests the next spectrum from the synchronised iterator + * wrapper, and validates it. + */ + private class InnerSpecValidator implements Runnable { + InnerIteratorSync iter = null; + Collection messages = new ArrayList(); + InnerLock lock = null; + int count = 0; + int iNumber = -1; + + public InnerSpecValidator(InnerIteratorSync aIterator, InnerLock aLock, int aNumber) { + iter = aIterator; + lock = aLock; + iNumber = aNumber; + } + + public void run() { + T s = null; + while ((s = iter.next()) != null) { + // I changed SpectrumType for Spectrum (according to the new + // PRIDE object model) + ArrayList tovalidate = new ArrayList(1); + tovalidate.add(s); + try { + // check cvMapping rules + addMessages(checkCvMapping(tovalidate, MzMLElement.Spectrum.getXpath()), msgL); + // check object rules + addMessages(validate(s), msgL); + + count++; + } catch (ValidatorException ve) { + ve.printStackTrace(); + } + } + lock.updateDoneCount(); + } + + public Collection getMessages() { + return messages; + } + + public int getCount() { + return count; + } + } + + private static void printUsage() { + printError("Usage:\n\n\t" + + MzMLValidator.class.getName() + + " \n\n\t\tWhere message level can be:\n\t\t - DEBUG\n\t\t - INFO\n\t\t - WARN\n\t\t - ERROR\n\t\t - FATAL"); + } + + private static void printError(String aMessage) { + System.err.println("\n\n" + aMessage + "\n\n"); + System.exit(1); + } + + private String printMessages(Collection aMessages) { + StringBuilder sb = new StringBuilder(); + if (aMessages.size() != 0) { + sb.append("\n\nThe following messages were obtained during the validation of your XML file:\n"); + for (Object aMessage : aMessages) { + ValidatorMessage lMessage = (ValidatorMessage) aMessage; + sb.append(" * " + lMessage + "\n"); + } + } else { + sb.append("\n\nCongratulations! Your XML file passed the semantic validation!\n\n"); + } + return sb.toString(); + } + + private void addMessages(Collection aNewMessages, MessageLevel aLevel) { + for (ValidatorMessage aNewMessage : aNewMessages) { + if (aNewMessage.getLevel().isHigher(aLevel) || aNewMessage.getLevel().isSame(aLevel)) { + addValidatorMessage(aNewMessage.getRule().getId(), aNewMessage, this.msgL); + } + } + } + + private void addSyncMessages(Map> sync_msgs, MessageLevel aLevel) { + for (String key : sync_msgs.keySet()) { + final List list = sync_msgs.get(key); + for (ValidatorMessage aNewMessage : list) { + if (aNewMessage.getLevel().isHigher(aLevel) + || aNewMessage.getLevel().isSame(aLevel)) { + addValidatorMessage(key, aNewMessage, this.msgL); + } + } + + } + + } + + private static MessageLevel getMessageLevel(String aLevel) { + aLevel = aLevel.trim(); + MessageLevel result = null; + if (aLevel.equals("DEBUG")) { + result = MessageLevel.DEBUG; + } else if (aLevel.equals("INFO")) { + result = MessageLevel.INFO; + } else if (aLevel.equals("WARN")) { + result = MessageLevel.WARN; + } else if (aLevel.equals("ERROR")) { + result = MessageLevel.ERROR; + } else if (aLevel.equals("FATAL")) { + result = MessageLevel.FATAL; + } + + return result; + } + + /** + * Method to reset all the fields in this validator. + * + * @throws CvRuleReaderException + * @throws ValidatorException + * @throws IOException + */ + protected void reset(String cvMappingRuleFileName, String objectRuleFileName) + throws CvRuleReaderException, ValidatorException, IOException { + // reset the collection of ValidatorMessages + if (this.msgs != null) { + this.msgs.clear(); + } + + // reset the message reporting level to the default + this.msgL = MessageLevel.WARN; + // reset the unmarshaller + this.unmarshaller = null; + // reset the progress counter + this.progress = 0; + + // restart the rules to skip + if (ruleFilterManager != null) + ruleFilterManager.restartRulesToSkip(); + + // delete all objectRules + this.getObjectRules().clear(); + // delete all cvMappingRules + this.getCvRuleManager().getCvRules().clear(); + + // set the new cvMapping rules + final FileInputStream cvMappingRuleFile = new FileInputStream(cvMappingRuleFileName); + this.setCvMappingRules(cvMappingRuleFile); + cvMappingRuleFile.close(); + + // set the new objectrules + final FileInputStream objectRuleFile = new FileInputStream(objectRuleFileName); + this.setObjectRules(objectRuleFile); + objectRuleFile.close(); + + } + + public ExtendedValidatorReport getExtendedReport() { + if (this.extendedReport != null) { + if (this.extendedReport.getTotalCvRules() == 0) + this.extendedReport.setCvRules(this.getCvRuleManager().getCvRules(), + this.ruleFilterManager); + } + return this.extendedReport; + + } +} diff --git a/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.form b/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.form new file mode 100644 index 0000000..6271189 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.form @@ -0,0 +1,456 @@ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.java b/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.java new file mode 100644 index 0000000..2e9fa34 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/MzMLValidatorGUI.java @@ -0,0 +1,957 @@ +/* + * MzMLValidatorGUI.java Created on __DATE__, __TIME__ + */ +package psidev.psi.ms; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Properties; + +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.filechooser.FileFilter; +import javax.xml.bind.JAXBException; + +import psidev.psi.ms.rulefilter.MaldiOrEsiCondition; +import psidev.psi.ms.rulefilter.RuleFilterAgent; +import psidev.psi.ms.rulefilter.RuleFilterManager; +import psidev.psi.ms.swingworker.SwingWorker; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.util.ValidatorReport; + +import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author __USER__ + */ +public class MzMLValidatorGUI extends javax.swing.JPanel implements RuleFilterAgent { + + private Exception error; + private SwingWorker sw; + private long runStartTime = -11; + private MzMLValidator validator = null; + protected RuleFilterManager ruleFilterManager; + private static final String DEFAULT_PROGRESS_MESSAGE = "Select a file and press validate..."; + + /** + * Creates new form MzMLValidatorGUI + */ + public MzMLValidatorGUI() { + + initComponents(); + + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // GEN-BEGIN:initComponents + // + private void initComponents() { + + buttonGroup1 = new javax.swing.ButtonGroup(); + buttonGroup2 = new javax.swing.ButtonGroup(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jTextInputFile = new javax.swing.JTextField(); + jButtonBrowse = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jRadioInfoLevel = new javax.swing.JRadioButton(); + jRadioWarnLevel = new javax.swing.JRadioButton(); + jRadioErrorLevel = new javax.swing.JRadioButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + jRadioMALDI = new javax.swing.JRadioButton(); + jRadioESI = new javax.swing.JRadioButton(); + jRadioOTHER = new javax.swing.JRadioButton(); + jPanel5 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextAreaMessages = new javax.swing.JTextArea(); + jPanel6 = new javax.swing.JPanel(); + jProgressBar = new javax.swing.JProgressBar(); + jPanel8 = new javax.swing.JPanel(); + jComboValidationType = new javax.swing.JComboBox(); + jPanel7 = new javax.swing.JPanel(); + jButtonValidate = new javax.swing.JButton(); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("File selection")); + + jLabel1.setText("mzML file to validate:"); + + jButtonBrowse.setText("Browse..."); + jButtonBrowse.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonBrowseActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel1Layout + .createSequentialGroup() + .addContainerGap() + .add(jLabel1) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jTextInputFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 372, + Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jButtonBrowse).addContainerGap())); + jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel1Layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLabel1) + .add(jButtonBrowse) + .add(jTextInputFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))); + + jPanel2.setBorder(javax.swing.BorderFactory + .createTitledBorder("Select minimal message level to display")); + + buttonGroup1.add(jRadioInfoLevel); + jRadioInfoLevel.setText("Info"); + + buttonGroup1.add(jRadioWarnLevel); + jRadioWarnLevel.setSelected(true); + jRadioWarnLevel.setText("Warn"); + + buttonGroup1.add(jRadioErrorLevel); + jRadioErrorLevel.setText("Error"); + + org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup(jPanel2Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel2Layout + .createSequentialGroup() + .add(27, 27, 27) + .add(jRadioInfoLevel) + .add(50, 50, 50) + .add(jRadioWarnLevel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 45, + Short.MAX_VALUE).add(jRadioErrorLevel).add(42, 42, 42))); + jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel2Layout + .createSequentialGroup() + .add(jPanel2Layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jRadioWarnLevel).add(jRadioInfoLevel).add(jRadioErrorLevel)) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Select one option")); + + jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Ionization source")); + + buttonGroup2.add(jRadioMALDI); + jRadioMALDI.setText("MALDI source"); + + buttonGroup2.add(jRadioESI); + jRadioESI.setSelected(true); + jRadioESI.setText("ESI source"); + + buttonGroup2.add(jRadioOTHER); + jRadioOTHER.setText("Other source"); + + org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout + .setHorizontalGroup(jPanel4Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel4Layout + .createSequentialGroup() + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE).add(jRadioMALDI) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jRadioESI) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jRadioOTHER))); + jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel4Layout + .createSequentialGroup() + .add(jPanel4Layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jRadioMALDI).add(jRadioESI).add(jRadioOTHER)) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + + org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel3Layout + .createSequentialGroup() + .addContainerGap() + .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel3Layout + .createSequentialGroup() + .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap())); + + jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Messages")); + + jTextAreaMessages.setColumns(20); + jTextAreaMessages.setLineWrap(true); + jTextAreaMessages.setRows(5); + jTextAreaMessages.setWrapStyleWord(true); + jScrollPane1.setViewportView(jTextAreaMessages); + + org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5); + jPanel5.setLayout(jPanel5Layout); + jPanel5Layout.setHorizontalGroup(jPanel5Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel5Layout + .createSequentialGroup() + .addContainerGap() + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 576, + Short.MAX_VALUE).addContainerGap())); + jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel5Layout + .createSequentialGroup() + .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 276, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + + jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Progress")); + + jProgressBar.setString("Select a file and press validate..."); + jProgressBar.setStringPainted(true); + + org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup(jPanel6Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel6Layout + .createSequentialGroup() + .addContainerGap() + .add(jProgressBar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 576, + Short.MAX_VALUE).addContainerGap())); + jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel6Layout + .createSequentialGroup() + .add(jProgressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + + jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Type of validation")); + + jComboValidationType.setModel(new javax.swing.DefaultComboBoxModel(new String[]{ + "MIAPE-compliant validation", "Semantic validation"})); + jComboValidationType.setToolTipText("Select the type of validation"); + jComboValidationType.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboValidationTypeActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8); + jPanel8.setLayout(jPanel8Layout); + jPanel8Layout.setHorizontalGroup(jPanel8Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel8Layout + .createSequentialGroup() + .add(51, 51, 51) + .add(jComboValidationType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(39, Short.MAX_VALUE))); + jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel8Layout + .createSequentialGroup() + .add(jComboValidationType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + + jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Action")); + + jButtonValidate.setText("Validate!"); + jButtonValidate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonValidateActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup(jPanel7Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + org.jdesktop.layout.GroupLayout.TRAILING, + jPanel7Layout + .createSequentialGroup() + .addContainerGap() + .add(jButtonValidate, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 242, + Short.MAX_VALUE).addContainerGap())); + jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING).add( + jPanel7Layout.createSequentialGroup().addContainerGap().add(jButtonValidate) + .addContainerGap(38, Short.MAX_VALUE))); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout + .createSequentialGroup() + .addContainerGap() + .add(layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(layout + .createSequentialGroup() + .add(layout + .createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING, + false) + .add(jPanel2, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(jPanel3, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout + .createParallelGroup( + org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel8, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(jPanel7, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)))).addContainerGap())); + layout.setVerticalGroup(layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout + .createSequentialGroup() + .addContainerGap() + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout + .createSequentialGroup() + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, + layout.createSequentialGroup() + .add(8, 8, 8) + .add(jPanel2, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(layout + .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(jPanel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, + org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE))); + }// + // GEN-END:initComponents + + private void jComboValidationTypeActionPerformed(java.awt.event.ActionEvent evt) { + if (isMIAPEValidationSelected()) { + enableRadioButtons(true); + } else if (isSemanticValidationSelected()) { + enableRadioButtons(false); + } + } + + private void enableRadioButtons(boolean b) { + this.jRadioESI.setEnabled(b); + this.jRadioMALDI.setEnabled(b); + this.jRadioOTHER.setEnabled(b); + } + + private void jButtonBrowseActionPerformed(ActionEvent evt) { + selectFile(); + + } + + private void jButtonValidateActionPerformed(ActionEvent evt) { + // Check input file. + String input = jTextInputFile.getText(); + if (input == null || input.trim().equals("")) { + JOptionPane.showMessageDialog(this, "Please specify an mzML file to validate!", + "No mzML file specified!", JOptionPane.WARNING_MESSAGE); + jTextInputFile.requestFocus(); + return; + } + // See if the file exists. + final File inputFile = new File(input); + if (!inputFile.exists()) { + JOptionPane.showMessageDialog(this, "The mzML file you specified ('" + input + + "') does not exist!", "Specified mzML file not found!", + JOptionPane.WARNING_MESSAGE); + jTextInputFile.requestFocus(); + return; + } + // make sure the input is not a directory! + if (inputFile.isDirectory()) { + JOptionPane.showMessageDialog(this, "The mzML file you specified ('" + input + + "') is not a file but a folder!", "Folder specified instead of file!", + JOptionPane.WARNING_MESSAGE); + jTextInputFile.requestFocus(); + return; + } + + // Reset the error. + error = null; + + // OK, we have a valid file to validate. + // Proceed with the work. + + // Disable GUI + jTextInputFile.setEnabled(false); + jButtonBrowse.setEnabled(false); + jButtonValidate.setEnabled(false); + jRadioInfoLevel.setEnabled(false); + jRadioWarnLevel.setEnabled(false); + jRadioErrorLevel.setEnabled(false); + jComboValidationType.setEditable(false); + enableRadioButtons(false); + + if (isMIAPEValidationSelected()) { + try { + this.ruleFilterManager = new RuleFilterManager(new File( + getProperty("miape.filter.rule.file"))); + // filter rules by the options of the user + } catch (JAXBException e1) { + // no filter rules + } catch (IllegalArgumentException e2) { + // no filter rules + } + } + // Call the SwingWorker that will start the validation. + sw = new SwingWorker() { + public Object construct() { + Collection messages = new ArrayList(); + jTextAreaMessages.setText(""); + jTextAreaMessages.setCaretPosition(0); + jProgressBar.setIndeterminate(true); + jProgressBar.setString("Initializing validator..."); + runStartTime = System.currentTimeMillis(); + try { + // Lazy cached validator. + if (validator == null) { + jProgressBar.setString("Loading configuration files..."); + + InputStream ontology = null; + if (new File(getProperty("ontologies.file")).exists()) { + System.out.println("Using file resource " + getProperty("ontologies.file")); + ontology = new FileInputStream(getProperty("ontologies.file")); + } else { + System.out.println("Using classpath resource " + getProperty("ontologies.file")); + ontology = MzMLValidator.class.getResourceAsStream("/" + getProperty("ontologies.file")); + } + + validator = new MzMLValidator(ontology, getMappingRuleFile(), + getObjectRuleFile(), MzMLValidatorGUI.this); + ontology.close(); + } else { + + // reset all validator fields except the ontologies + validator.reset(getMappingRuleFile(), getObjectRuleFile()); + } + // this will add to the validator the rules to be skipped + if (isMIAPEValidationSelected() && ruleFilterManager != null) { + ruleFilterManager.filterRulesByUserOptions(getSelectedOptions()); + } + + // common settings to set each time the validation button is + // pressed + validator.setValidatorGUI(MzMLValidatorGUI.this); + validator.setMessageReportLevel(getLevel()); + validator.setSchemaUri(getSchemaUri()); + validator.setSkipValidation(skipValidation()); + + // set the rule filter manager + validator.setRuleFilterManager(ruleFilterManager); + + jProgressBar.setString("Indexing mzML file..."); + final Collection validationResult = validator + .startValidation(inputFile); + messages.addAll(validationResult); + + } catch (Exception e) { + e.printStackTrace(); + notifyOfError(e); + } + return messages; + } + + public void finished() { + validationDone(); + } + }; + sw.start(); + } + + public String getMappingRuleFile() { + // by default: + String mappingRuleFile = "ms-mapping.xml"; + if (this.jComboValidationType.getSelectedItem().equals( + ValidationType.MIAPE_VALIDATION.getName())) { + mappingRuleFile = getProperty("mapping.rule.file.miape.validation"); + } else if (this.jComboValidationType.getSelectedItem().equals( + ValidationType.SEMANTIC_VALIDATION.getName())) { + mappingRuleFile = getProperty("mapping.rule.file.semantic.validation"); + } + if (new File(mappingRuleFile).exists()) { + return mappingRuleFile; + } else { + try { + return Resources.extractResource("/" + mappingRuleFile).getAbsolutePath(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + throw new NullPointerException("Could not locate mapping rule file at " + mappingRuleFile); + } + + public String getObjectRuleFile() { + // by default: + String objectRuleFile = "ObjectRules.xml"; + if (isMIAPEValidationSelected()) { + objectRuleFile = getProperty("object.rule.file.miape.validation"); + } else if (isSemanticValidationSelected()) { + objectRuleFile = getProperty("object.rule.file.semantic.validation"); + } + if (new File(objectRuleFile).exists()) { + return objectRuleFile; + } else { + try { + return Resources.extractResource("/" + objectRuleFile).getAbsolutePath(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + throw new NullPointerException("Could not locate object rule file at " + objectRuleFile); + } + + boolean isSemanticValidationSelected() { + return this.jComboValidationType.getSelectedItem().equals( + ValidationType.SEMANTIC_VALIDATION.getName()); + } + + boolean isMIAPEValidationSelected() { + return this.jComboValidationType.getSelectedItem().equals( + ValidationType.MIAPE_VALIDATION.getName()); + } + + private String getProperty(String propertyName) { + ClassLoader cl = this.getClass().getClassLoader(); + InputStream is; + + is = cl.getResourceAsStream("validation.properties"); + if (is == null) { + throw new IllegalArgumentException("validation.properties" + " file not found"); + } + + Properties prop = new Properties(); + try { + prop.load(is); + is.close(); + } catch (IOException e) { + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + + return prop.getProperty(propertyName); + } + + private void validationDone() { + jProgressBar.setValue(jProgressBar.getMaximum()); + if (error != null) { + JOptionPane.showMessageDialog(this, + new String[]{"A problem occurred when attempting to validate the mzML file!", + error.getMessage()}, "Error occurred during validation!", + JOptionPane.ERROR_MESSAGE); + } + Collection messages = (Collection) sw.get(); + + showMessages(messages); + + jProgressBar.setIndeterminate(false); + jProgressBar.setValue(0); + // Calculate last run time. + long delta = System.currentTimeMillis() - runStartTime; + // Reset run start time and moment. + runStartTime = -1; + jProgressBar.setString(DEFAULT_PROGRESS_MESSAGE + " (last run took " + (delta / 1000) + + " seconds)"); + // Re-enable GUI. + jTextInputFile.setEnabled(true); + jButtonBrowse.setEnabled(true); + jButtonValidate.setEnabled(true); + jRadioInfoLevel.setEnabled(true); + jRadioWarnLevel.setEnabled(true); + jRadioErrorLevel.setEnabled(true); + jComboValidationType.setEnabled(true); + jComboValidationTypeActionPerformed(null); + + showExtendedReportDialog(messages.size()); + // showReportDialog(); + + } + + private void showReportDialog() { + ValidatorReport report = validator.getReport(); + StringBuilder sb = new StringBuilder(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append("
CvMappingRule total count: ") + .append(validator.getCvRuleManager().getCvRules().size()).append("
CvMappingRules not run: ") + .append(report.getCvRulesNotChecked().size()).append("
CvMappingRules with invalid Xpath: ") + .append(report.getCvRulesInvalidXpath().size()).append("
CvMappingRules with valid Xpath, but no hit: ") + .append(report.getCvRulesValidXpath().size()).append("
CvMappingRules run & valid: ") + .append(report.getCvRulesValid().size()).append("
"); + + JOptionPane.showMessageDialog(this, new String[]{"", sb.toString()}, + "CvMappingRule Report", JOptionPane.INFORMATION_MESSAGE); + + } + + private void showExtendedReportDialog(int messageNumber) { + ExtendedValidatorReport report = validator.getExtendedReport(); + StringBuilder sb = new StringBuilder(""); + + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + + sb.append(""); + + sb.append("
CvMappingRule total count: ") + .append(report.getTotalCvRules()).append("
CvMappingRules not run: ") + .append(report.getCvRulesNotChecked().size()).append("
"); + // red in case of more than 0 invalid rules + if (report.getCvRulesInvalidXpath().size() > 0) { + sb.append(""); + } + sb.append("CvMappingRules with invalid Xpath: "); + if (report.getCvRulesInvalidXpath().size() > 0) { + sb.append(""); + } + sb.append(""); + if (report.getCvRulesInvalidXpath().size() > 0) { + sb.append(""); + } + sb.append(report.getCvRulesInvalidXpath().size()); + if (report.getCvRulesInvalidXpath().size() > 0) { + sb.append(""); + } + sb.append("
CvMappingRules with valid Xpath, but no hit: ") + .append(report.getCvRulesValidXpath().size()).append("
CvMappingRules run & valid: ") + .append(report.getCvRulesValid().size()).append("
ObjectRules total count:" + + report.getTotalObjectRules() + "
ObjectRules not run:" + + report.getObjectRulesNotChecked().size() + "
"); + // red in case of more than 0 invalid rules + if (report.getObjectRulesInvalid().size() > 0) { + sb.append(""); + } + sb.append("ObjectRules run & invalid:"); + if (report.getObjectRulesInvalid().size() > 0) { + sb.append(""); + } + sb.append(""); + if (report.getObjectRulesInvalid().size() > 0) { + sb.append(""); + } + sb.append(report.getObjectRulesInvalid().size()); + if (report.getObjectRulesInvalid().size() > 0) { + sb.append(""); + } + sb.append("
ObjectRules run & valid:" + + report.getObjectRulesValid().size() + "
"); + if (messageNumber > 0) { + sb.append(""); + } + sb.append("Messages received: "); + if (messageNumber > 0) { + sb.append(""); + } + sb.append(""); + if (messageNumber > 0) { + sb.append(""); + } + sb.append(messageNumber); + if (messageNumber > 0) { + sb.append(""); + } + sb.append("
"); + + JOptionPane.showMessageDialog(this, new String[]{"", sb.toString()}, + "Rule Execution Report", JOptionPane.INFORMATION_MESSAGE); + + } + + private void showMessages(Collection aMessages) { + Collection messages = (Collection) sw.get(); + if (messages != null && messages.size() > 0) { + this.jTextAreaMessages.setText(printValidatorMessages(messages)); + this.jTextAreaMessages.setCaretPosition(0); + } else { + this.jTextAreaMessages.setText("\n\nNo messages were returned by the validator."); + if (error == null) { + JOptionPane.showMessageDialog(MzMLValidatorGUI.this, + "Your mzIdentML file validated at the current message level.", + "No messages produced.", JOptionPane.INFORMATION_MESSAGE); + } + } + + this.jTextAreaMessages.append(validator.printValidatorReport()); + // this.jTextAreaMessages.append(validator.printCvContextReport()); + } + + private String printValidatorMessages(Collection messages) { + StringBuffer sb = new StringBuffer( + "\n\nThe following messages were obtained during the validation of your XML file:\n\n\n"); + int count = 0; + for (ValidatorMessage message : messages) { + // only show messages that have the same (or higher) message level + // as selected + if (message.getLevel().isSame(getLevel()) || message.getLevel().isHigher(getLevel())) { + count++; + sb.append("\n\nMessage ").append(count).append(":\n"); + sb.append(" Level: ").append(message.getLevel()).append("\n"); + sb.append(" ").append(message.getContext()).append("\n"); + sb.append(" --> ").append(message.getMessage()).append("\n"); + if (message.getRule() != null && message.getRule().getHowToFixTips() != null) { + for (String howToFixTip : message.getRule().getHowToFixTips()) { + sb.append(" Tip: " + howToFixTip).append("\n"); + } + } + } + } + + return sb.toString(); + } + + private void selectFile() { + File startHere = new File("/"); + // Open the filechooser on the root or the folder the user + // already specified (if it exists). + if (!jTextInputFile.getText().trim().equals("")) { + File f = new File(jTextInputFile.getText().trim()); + if (f.exists()) { + startHere = f; + } + } + JFileChooser jfc = new JFileChooser(startHere); + int returnVal = 0; + jfc.setDialogType(JFileChooser.OPEN_DIALOG); + jfc.setDialogTitle("Select mzML file to validate"); + jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); + jfc.setFileFilter(new FileFilter() { + public boolean accept(File f) { + boolean result = false; + if (f.isDirectory() || f.getName().toLowerCase().endsWith(".mzml") + || f.getName().toLowerCase().endsWith(".xml")) { + result = true; + } + return result; + } + + public String getDescription() { + return "mzML files"; + } + }); + returnVal = jfc.showOpenDialog(jTextInputFile); + if (returnVal == JFileChooser.APPROVE_OPTION) { + jTextInputFile.setText(jfc.getSelectedFile().getAbsoluteFile().toString()); + } + + } + + private MessageLevel getLevel() { + MessageLevel result = null; + if (jRadioInfoLevel.isSelected()) { + result = MessageLevel.INFO; + } else if (jRadioWarnLevel.isSelected()) { + result = MessageLevel.WARN; + } else if (jRadioErrorLevel.isSelected()) { + result = MessageLevel.ERROR; + } + return result; + } + + private URI getSchemaUri() { + // ToDo: implement + return validator.getSchemaUri(); + } + + private boolean skipValidation() { + // ToDo: implement + return false; + } + + public void notifyOfError(Exception e) { + error = e; + } + + public void initProgress(int min, int max, int current) { + jProgressBar.setIndeterminate(false); + jProgressBar.setMinimum(min); + jProgressBar.setMaximum(max); + jProgressBar.setValue(current); + } + + public void setProgress(int value, String message) { + if (value > jProgressBar.getMaximum()) { + // throw new + // IllegalArgumentException("You tried to set the progress to value '" + // + value + // + "', but the maximum was '" + jProgressBar.getMaximum() + "'!"); + value = jProgressBar.getMaximum(); + } + jProgressBar.setValue(value); + jProgressBar.setString(message); + } + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel(new WindowsLookAndFeel()); + } catch (UnsupportedLookAndFeelException e) { + System.out.println("No Windows lookAndFeel found"); + } + MzMLValidatorGUI jpanValidator = new MzMLValidatorGUI(); + + if (args != null && args.length == 1) { + jpanValidator.jTextInputFile.setText(args[0]); + } + + JFrame validatorFrame = new JFrame("mzML validator GUI (mzML version 1.0)"); + validatorFrame.getContentPane().add(jpanValidator, BorderLayout.CENTER); + validatorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + validatorFrame.setResizable(false); + validatorFrame.addWindowListener(new WindowAdapter() { + /** + * Invoked when a window is in the process of being closed. The + * close operation can be overridden at this point. + */ + public void windowClosing(WindowEvent e) { + e.getWindow().setVisible(false); + e.getWindow().dispose(); + System.exit(0); + } + }); + validatorFrame.setLocation(100, 100); + validatorFrame.pack(); + validatorFrame.setVisible(true); + } + + public HashMap getSelectedOptions() { + HashMap conditionSet = new HashMap(); + if (this.jRadioESI.isSelected()) { + conditionSet.put(MaldiOrEsiCondition.getID(), MaldiOrEsiCondition.ESI.getOption()); + } else if (this.jRadioMALDI.isSelected()) { + conditionSet.put(MaldiOrEsiCondition.getID(), MaldiOrEsiCondition.MALDI.getOption()); + } else if (this.jRadioOTHER.isSelected()) { + conditionSet.put(MaldiOrEsiCondition.getID(), MaldiOrEsiCondition.OTHER.getOption()); + } + return conditionSet; + } + // GEN-BEGIN:variables + // Variables declaration - do not modify + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.ButtonGroup buttonGroup2; + private javax.swing.JButton jButtonBrowse; + private javax.swing.JButton jButtonValidate; + private javax.swing.JComboBox jComboValidationType; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JProgressBar jProgressBar; + private javax.swing.JRadioButton jRadioESI; + private javax.swing.JRadioButton jRadioErrorLevel; + private javax.swing.JRadioButton jRadioInfoLevel; + private javax.swing.JRadioButton jRadioMALDI; + private javax.swing.JRadioButton jRadioOTHER; + private javax.swing.JRadioButton jRadioWarnLevel; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jTextAreaMessages; + private javax.swing.JTextField jTextInputFile; + // End of variables declaration +} diff --git a/validator/src/main/java/psidev/psi/ms/Resources.java b/validator/src/main/java/psidev/psi/ms/Resources.java new file mode 100644 index 0000000..bf92bb1 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/Resources.java @@ -0,0 +1,100 @@ +package psidev.psi.ms; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import org.apache.commons.io.FilenameUtils; + +/** + * Provides convenience methods to extract resources from the classpath. + * + * @author Nils Hoffmann + */ +public class Resources { + + /** + * Extracts a resource using the classloader of {@code Resources} to locate the resource + * given by {@code resourcePath}. The extracted resource will be placed in the default + * temporary directory as returned by {@code System.getProperty(java.io.tmpdir)}, + * with the same filename as the original resource (minus path prefixes). + * + * @param resourcePath the path of the resource + * @return the extracted file + * @throws IOException + */ + public static File extractResource(String resourcePath) throws IOException { + File tmpDir = new File(System.getProperty("java.io.tmpdir")); + return extractResource(Resources.class, resourcePath, new File(tmpDir,FilenameUtils.getName(resourcePath))); + } + + /** + * Extracts a resource using the classloader of {@code Resources} to locate the resource + * given by {@code resourcePath}. The extracted resource will be placed in directory + * {@code destDir}. + * + * @param resourcePath the path of the resource + * @param destDir the destination directory + * @return the extracted file + * @see #extractResource(java.lang.Class, java.lang.String, java.io.File) + */ + public static File extractResource(String resourcePath, File destDir) { + return extractResource(Resources.class, resourcePath, destDir); + } + + /** + * Extracts a resource using the classloader of {@code clazz} to locate the resource + * given by {@code resourcePath}. The extracted resource will be placed in directory + * {@code destDir}. + * + * @param clazz the class whose classloader should be used + * @param resourcePath the path of the resource + * @param destDir the destination directory + * @return the extracted file + */ + public static File extractResource(Class clazz, String resourcePath, File destDir) { + System.out.println("Extracting " + resourcePath + " to directory: " + destDir); + if (!destDir.exists()) { + destDir.mkdirs(); + } + URL resourceURL = clazz.getResource(resourcePath); + if (resourceURL == null) { + throw new NullPointerException( + "Could not retrieve resource for path: " + resourcePath); + } + File outputFile = null; + try { + InputStream resourceInputStream = resourceURL.openStream(); + InputStream in = null; + OutputStream out = null; + try { + String outname = new File(resourceURL.getPath()).getName(); + outname = outname.replaceAll("%20", " "); + in = new BufferedInputStream(resourceInputStream); + outputFile = new File(destDir, outname); + out = new BufferedOutputStream(new FileOutputStream(outputFile)); + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + + return outputFile; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/ValidationType.java b/validator/src/main/java/psidev/psi/ms/ValidationType.java new file mode 100644 index 0000000..0b0742d --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/ValidationType.java @@ -0,0 +1,14 @@ +package psidev.psi.ms; + +public enum ValidationType { + MIAPE_VALIDATION("MIAPE-compliant validation"), SEMANTIC_VALIDATION("Semantic validation"); + private final String name; + + ValidationType(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionListType.java new file mode 100644 index 0000000..371c406 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionListType.java @@ -0,0 +1,239 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of acquisitions . + * + *

Java class for AcquisitionListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="AcquisitionListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="acquisition" type="{http://psi.hupo.org/schema_revision/mzML_0.93}AcquisitionType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *       <attribute name="methodOfCombination" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="spectrumType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AcquisitionListType", propOrder = { + "acquisition" +}) +public class AcquisitionListType { + + @XmlElement(required = true) + protected List acquisition; + @XmlAttribute(required = true) + protected BigInteger count; + @XmlAttribute(required = true) + protected String methodOfCombination; + @XmlAttribute(required = true) + protected String spectrumType; + + + private String elementName = "acquisitionList"; + + public AcquisitionListType() {} + + public AcquisitionListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public AcquisitionListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + String methodOfCombination = ele.getAttribute("methodOfCombination"); + if (!methodOfCombination.equals("")) { // getAttribute returns empty String if no value was specified + setMethodOfCombination(methodOfCombination); + } + String spectrumType = ele.getAttribute("spectrumType"); + if (!spectrumType.equals("")) { // getAttribute returns empty String if no value was specified + setSpectrumType(spectrumType); + } + // create other elements + NodeList nl = ele.getElementsByTagName("acquisition"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getAcquisition().add(new AcquisitionType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + + /** + * Gets the value of the acquisition property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the acquisition property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAcquisition().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link AcquisitionType } + * + * + */ + public List getAcquisition() { + if (acquisition == null) { + acquisition = new ArrayList(); + } + return this.acquisition; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + + /** + * Gets the value of the methodOfCombination property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMethodOfCombination() { + return methodOfCombination; + } + + /** + * Sets the value of the methodOfCombination property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMethodOfCombination(String value) { + this.methodOfCombination = value; + } + + /** + * Gets the value of the spectrumType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSpectrumType() { + return spectrumType; + } + + /** + * Sets the value of the spectrumType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSpectrumType(String value) { + this.spectrumType = value; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionType.java new file mode 100644 index 0000000..6cd1e61 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/AcquisitionType.java @@ -0,0 +1,190 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Scan or acquisition from original raw file used to create this peak list, as specified in sourceFile. + * + *

Java class for AcquisitionType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="AcquisitionType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <attribute name="acqNumber" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="sourceFileRef" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="spectrumRef" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+  *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AcquisitionType") +public class AcquisitionType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected int acqNumber; + @XmlAttribute(required = true) + protected String sourceFileRef; + @XmlAttribute(required = true) + protected String spectrumRef; + + + private String elementName = "acquisition"; + + public AcquisitionType() {} + + public AcquisitionType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public AcquisitionType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String acqNumber = ele.getAttribute("acqNumber"); + if (!acqNumber.equals("")) { // getAttribute returns empty String if no value was specified + setAcqNumber(Integer.parseInt(acqNumber)); + } + String sourceFileRef = ele.getAttribute("sourceFileRef"); + if (!sourceFileRef.equals("")) { // getAttribute returns empty String if no value was specified + setSourceFileRef(sourceFileRef); + } + String spectrumRef = ele.getAttribute("spectrumRef"); + if (!spectrumRef.equals("")) { // getAttribute returns empty String if no value was specified + setSpectrumRef(spectrumRef); + } + // load elements + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the acqNumber property. + * + */ + public int getAcqNumber() { + return acqNumber; + } + + /** + * Sets the value of the acqNumber property. + * + */ + public void setAcqNumber(int value) { + this.acqNumber = value; + } + + /** + * Gets the value of the sourceFileRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSourceFileRef() { + return sourceFileRef; + } + + /** + * Sets the value of the sourceFileRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSourceFileRef(String value) { + this.sourceFileRef = value; + } + + /** + * Gets the value of the spectrumRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSpectrumRef() { + return spectrumRef; + } + + /** + * Sets the value of the spectrumRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSpectrumRef(String value) { + this.spectrumRef = value; + } + + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/BinaryDataArrayType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/BinaryDataArrayType.java new file mode 100644 index 0000000..f5631a1 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/BinaryDataArrayType.java @@ -0,0 +1,236 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.bind.annotation.*; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.math.BigInteger; + + +/** + * The structure into which encoded binary data goes. + * + *

Java class for BinaryDataArrayType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="BinaryDataArrayType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <sequence>
+ *         <element name="binary" type="{http://www.w3.org/2001/XMLSchema}base64Binary"/>
+ *       </sequence>
+ *       <attribute name="arrayLength" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *       <attribute name="dataProcessingRef" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="encodedLength" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "BinaryDataArrayType", propOrder = { + "binary" +}) +public class BinaryDataArrayType + extends ParamGroupType +{ + + @XmlElement(required = true) + protected byte[] binary; + @XmlAttribute(required = true) + protected BigInteger arrayLength; + @XmlAttribute + protected String dataProcessingRef; + @XmlAttribute(required = true) + protected BigInteger encodedLength; + + + private String elementName = "binaryDataArray"; + + public BinaryDataArrayType() {} + + public BinaryDataArrayType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public BinaryDataArrayType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String arrayLength = ele.getAttribute("arrayLength"); + if (!arrayLength.equals("")) { // getAttribute returns empty String if no value was specified + setArrayLength(new BigInteger(arrayLength)); + } + String dataProcessingRef = ele.getAttribute("dataProcessingRef"); + if (!dataProcessingRef.equals("")) { // getAttribute returns empty String if no value was specified + setDataProcessingRef(dataProcessingRef); + } + String encodedLength = ele.getAttribute("encodedLength"); + if (!encodedLength.equals("")) { // getAttribute returns empty String if no value was specified + setEncodedLength(new BigInteger(encodedLength)); + } + + // load elements + NodeList nl = ele.getElementsByTagName("binary"); + // we only expect one such element! + if (nl.getLength() == 1) { + Node data = nl.item(0); + binary = Base64.decode(data.getTextContent()); + } else { + throw new IllegalStateException("Expected only one 'binary' element, but found: " + nl.getLength()); + } + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the binary property. + * + * @return + * possible object is + * byte[] + */ + public byte[] getBinary() { + return binary; + } + + /** + * Sets the value of the binary property. + * + * @param value + * allowed object is + * byte[] + */ + public void setBinary(byte[] value) { + this.binary = ((byte[]) value); + } + + /** + * Gets the value of the arrayLength property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getArrayLength() { + return arrayLength; + } + + /** + * Sets the value of the arrayLength property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setArrayLength(BigInteger value) { + this.arrayLength = value; + } + + + /** + * Gets the value of the dataProcessingRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDataProcessingRef() { + return dataProcessingRef; + } + + /** + * Sets the value of the dataProcessingRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDataProcessingRef(String value) { + this.dataProcessingRef = value; + } + + + /** + * Gets the value of the encodedLength property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getEncodedLength() { + return encodedLength; + } + + /** + * Sets the value of the encodedLength property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setEncodedLength(BigInteger value) { + this.encodedLength = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVListType.java new file mode 100644 index 0000000..b540781 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of CV + * + *

Java class for CVListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CVListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="cv" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CVListType", propOrder = { + "cv" +}) +public class CVListType { + + @XmlElement(required = true) + protected List cv; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "cvList"; + + public CVListType() {} + + public CVListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public CVListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("cv"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getCv().add(new CVType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the cv property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cv property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCv().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CVType } + * + * + */ + public List getCv() { + if (cv == null) { + cv = new ArrayList(); + } + return this.cv; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVParamType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVParamType.java new file mode 100644 index 0000000..e9ccf02 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVParamType.java @@ -0,0 +1,291 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * This element holds additional data or annotation. Only controlled values are allowed here. + * + *

Java class for CVParamType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CVParamType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="accession" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="cvLabel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="unitAccession" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="unitName" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="value" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CVParamType") +public class CVParamType { + + @XmlAttribute(required = true) + protected String accession; + @XmlAttribute(required = true) + protected String cvLabel; + @XmlAttribute(required = true) + protected String name; + @XmlAttribute + protected String unitAccession; + @XmlAttribute + protected String unitName; + @XmlAttribute + protected String value; + + + + private String elementName = "cvParam"; + + public CVParamType() {} + + public CVParamType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public CVParamType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // string + String accession = ele.getAttribute("accession"); + if (!accession.equals("")) { // getAttribute returns empty String if no value was specified + setAccession(accession); + } + String cvLabel = ele.getAttribute("cvLabel"); + if (!cvLabel.equals("")) { // getAttribute returns empty String if no value was specified + setCvLabel(cvLabel); + } + // uri represented as String + String name = ele.getAttribute("name"); + if (!name.equals("")) { // getAttribute returns empty String if no value was specified + setName(name); + } + String unitAccession = ele.getAttribute("unitAccession"); + if (!unitAccession.equals("")) { // getAttribute returns empty String if no value was specified + setUnitAccession(unitAccession); + } + // int + String unitName = ele.getAttribute("unitName"); + if (!unitName.equals("")) { // getAttribute returns empty String if no value was specified + setUnitName(unitName); + } + String value = ele.getAttribute("value"); + if (!value.equals("")) { // getAttribute returns empty String if no value was specified + setValue(value); + } + + + } + } + + //////////////////// + // Getter + Setter + + + /** + * Gets the value of the accession property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAccession() { + return accession; + } + + /** + * Sets the value of the accession property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAccession(String value) { + this.accession = value; + } + + /** + * Gets the value of the cvLabel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCvLabel() { + return cvLabel; + } + + /** + * Sets the value of the cvLabel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCvLabel(String value) { + this.cvLabel = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the unitAccession property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUnitAccession() { + return unitAccession; + } + + /** + * Sets the value of the unitAccession property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUnitAccession(String value) { + this.unitAccession = value; + } + + /** + * Gets the value of the unitName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUnitName() { + return unitName; + } + + /** + * Sets the value of the unitName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUnitName(String value) { + this.unitName = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVType.java new file mode 100644 index 0000000..07f6818 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/CVType.java @@ -0,0 +1,225 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Information about an ontology/CV source and a short 'lookup' tag to refer to. + * + *

Java class for CVType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CVType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="URI" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="cvLabel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="fullName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CVType") +public class CVType { + + @XmlAttribute(name = "URI", required = true) + protected String uri; + @XmlAttribute(required = true) + protected String cvLabel; + @XmlAttribute(required = true) + protected String fullName; + @XmlAttribute + protected String version; + + + private String elementName = "cv"; + + public CVType() {} + + public CVType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public CVType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String URI = ele.getAttribute("URI"); + if (!URI.equals("")) { // getAttribute returns empty String if no value was specified + setURI(URI); + } + String cvLabel = ele.getAttribute("cvLabel"); + if (!cvLabel.equals("")) { // getAttribute returns empty String if no value was specified + setCvLabel(cvLabel); + } + String fullName = ele.getAttribute("fullName"); + if (!fullName.equals("")) { // getAttribute returns empty String if no value was specified + setFullName(fullName); + } + String version = ele.getAttribute("version"); + if (!version.equals("")) { // getAttribute returns empty String if no value was specified + setVersion(version); + } + // load elements + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the uri property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getURI() { + return uri; + } + + /** + * Sets the value of the uri property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setURI(String value) { + this.uri = value; + } + + /** + * Gets the value of the cvLabel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCvLabel() { + return cvLabel; + } + + /** + * Sets the value of the cvLabel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCvLabel(String value) { + this.cvLabel = value; + } + + /** + * Gets the value of the fullName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFullName() { + return fullName; + } + + /** + * Sets the value of the fullName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFullName(String value) { + this.fullName = value; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentListType.java new file mode 100644 index 0000000..dccbe6e --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentListType.java @@ -0,0 +1,191 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List with the different components used in the mass spectrometer. + * + *

Java class for ComponentListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ComponentListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence maxOccurs="unbounded" minOccurs="3">
+ *         <choice>
+ *           <element name="source" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ComponentType"/>
+ *           <element name="analyzer" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ComponentType"/>
+ *           <element name="detector" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ComponentType"/>
+ *         </choice>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ComponentListType", propOrder = { + "sourceOrAnalyzerOrDetector" +}) +public class ComponentListType { + + @XmlElementRefs({ + @XmlElementRef(name = "detector", namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", type = JAXBElement.class), + @XmlElementRef(name = "analyzer", namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", type = JAXBElement.class) + }) + protected List sources; + protected List analyzers; + protected List detectors; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "componentList"; + + public ComponentListType() {} + + public ComponentListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ComponentListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("detector"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getDetector().add(new ComponentType((Element) nl.item(i))); + } + nl = null; + nl = ele.getElementsByTagName("source"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSource().add(new ComponentType((Element) nl.item(i))); + } + nl = null; + nl = ele.getElementsByTagName("analyzer"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getAnalyzer().add(new ComponentType((Element) nl.item(i))); + } + + } + } + + //////////////////// + // Getter + Setter + + public List getSource() { + if (sources == null) { + sources = new ArrayList(); + } + return this.sources; + } + + public List getAnalyzer() { + if (analyzers == null) { + analyzers = new ArrayList(); + } + return this.analyzers; + } + + public List getDetector() { + if (detectors == null) { + detectors = new ArrayList(); + } + return this.detectors; + } + + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentType.java new file mode 100644 index 0000000..16b3c47 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ComponentType.java @@ -0,0 +1,133 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + *

Java class for ComponentType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ComponentType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <attribute name="order" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ComponentType") +public class ComponentType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected int order; + + + private String elementName1 = "detector"; + private String elementName2 = "source"; + private String elementName3 = "analyzer"; + + public ComponentType() {} + + public ComponentType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ComponentType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + NodeList nl = document.getElementsByTagName(elementName1); + if (nl.getLength() == 0) { // if this element name did not match, try the next + nl = document.getElementsByTagName(elementName2); + } + if (nl.getLength() == 0) { // if this element name did not match, try the next + nl = document.getElementsByTagName(elementName3); + } + if (nl.getLength() == 1) { // we found one element! now we can create the Object + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected one '" + elementName1 + "' element " + + "or one '" + elementName2 + "' element " + + "or one '" + elementName3 + "' element " + + ", but found: " + nl.getLength()); + } + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String order = ele.getAttribute("order"); + if (!order.equals("")) { // getAttribute returns empty String if no value was specified + setOrder(Integer.parseInt(order)); + } + // load elements + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the order property. + * + */ + public int getOrder() { + return order; + } + + /** + * Sets the value of the order property. + * + */ + public void setOrder(int value) { + this.order = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ContactType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ContactType.java new file mode 100644 index 0000000..cdf711b --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ContactType.java @@ -0,0 +1,98 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Audit information concerning the means by which the originator/owner of this mzML file can be identified, and contacted if necessary. + * + *

Java class for ContactType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ContactType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="institution" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="URI" type="{http://www.w3.org/2001/XMLSchema}anyURI" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ + + +public class ContactType + extends ParamGroupType +{ + + + private String elementName = "contact"; + + public ContactType() {} + + public ContactType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ContactType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + + + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingListType.java new file mode 100644 index 0000000..e2b3be8 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of data processing applied to this data. + * + *

Java class for DataProcessingListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DataProcessingListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="dataProcessing" type="{http://psi.hupo.org/schema_revision/mzML_0.93}DataProcessingType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DataProcessingListType", propOrder = { + "dataProcessing" +}) +public class DataProcessingListType { + + @XmlElement(required = true) + protected List dataProcessing; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "dataProcessingList"; + + public DataProcessingListType() {} + + public DataProcessingListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public DataProcessingListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("dataProcessing"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getDataProcessing().add(new DataProcessingType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the dataProcessing property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the dataProcessing property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getDataProcessing().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link DataProcessingType } + * + * + */ + public List getDataProcessing() { + if (dataProcessing == null) { + dataProcessing = new ArrayList(); + } + return this.dataProcessing; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingType.java new file mode 100644 index 0000000..b4baacb --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/DataProcessingType.java @@ -0,0 +1,327 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * Description of the software, and the way in which it was used to generate the peak list. + * + *

Java class for DataProcessingType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DataProcessingType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="processingMethod" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *                 <attribute name="order" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *               </extension>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="softwareRef" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DataProcessingType", propOrder = { + "processingMethod" +}) +public class DataProcessingType { + + @XmlElement(required = true) + protected List processingMethod; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected String softwareRef; + + + private String elementName = "dataProcessing"; + + public DataProcessingType() {} + + public DataProcessingType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public DataProcessingType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String softwareRef = ele.getAttribute("softwareRef"); + if (!softwareRef.equals("")) { // getAttribute returns empty String if no value was specified + setSoftwareRef(softwareRef); + } + // load elements + NodeList nl = ele.getElementsByTagName("processingMethod"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getProcessingMethod().add(new ProcessingMethod((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the processingMethod property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the processingMethod property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getProcessingMethod().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link DataProcessingType.ProcessingMethod } + * + * + */ + public List getProcessingMethod() { + if (processingMethod == null) { + processingMethod = new ArrayList(); + } + return this.processingMethod; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the softwareRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSoftwareRef() { + return softwareRef; + } + + /** + * Sets the value of the softwareRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSoftwareRef(String value) { + this.softwareRef = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+     *       <attribute name="order" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+     *     </extension>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class ProcessingMethod + extends ParamGroupType + { + + @XmlAttribute + protected BigInteger order; + + + private String elementName = "processingMethod"; + + public ProcessingMethod() {} + + public ProcessingMethod(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ProcessingMethod(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String order = ele.getAttribute("order"); + if (!order.equals("")) { // getAttribute returns empty String if no value was specified + setOrder(new BigInteger(order)); + } + // load elements + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the order property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getOrder() { + return order; + } + + /** + * Sets the value of the order property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setOrder(BigInteger value) { + this.order = value; + } + + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileChecksumType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileChecksumType.java new file mode 100644 index 0000000..ebbec44 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileChecksumType.java @@ -0,0 +1,166 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Checksum to verify the file. + * + *

Java class for FileChecksumType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="FileChecksumType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "FileChecksumType", propOrder = { + "value" +}) +public class FileChecksumType { + + @XmlValue + protected String value; + @XmlAttribute(required = true) + protected String type; + + + private String elementName = "fileChecksum"; + + public FileChecksumType() {} + + public FileChecksumType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public FileChecksumType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String type = ele.getAttribute("type"); + if (!type.equals("")) { // getAttribute returns empty String if no value was specified + setType(type); + } + // load elements + // load element value + //ToDo: check! + String nodeValue = ele.getTextContent(); + if (!nodeValue.equals("")) { + value = nodeValue; + } + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileDescriptionType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileDescriptionType.java new file mode 100644 index 0000000..28665ee --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/FileDescriptionType.java @@ -0,0 +1,215 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * Information pertaining to the entire mzML file (i.e. not specific to any part of the data set) is stored here. + * + *

Java class for FileDescriptionType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="FileDescriptionType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="fileContent" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType"/>
+ *         <element name="sourceFileList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SourceFileListType" minOccurs="0"/>
+ *         <element name="contact" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ContactType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "FileDescriptionType", propOrder = { + "fileContent", + "sourceFileList", + "contact" +}) +public class FileDescriptionType { + + @XmlElement(required = true) + protected ParamGroupType fileContent; + protected SourceFileListType sourceFileList; + @XmlElement(required = true) + protected List contact; + + + private String elementName = "fileDescription"; + + public FileDescriptionType() {} + + public FileDescriptionType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public FileDescriptionType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // load elements + NodeList nl = ele.getElementsByTagName("fileContent"); + // we only expect one such element! + if (nl.getLength() == 1) { + fileContent = new ParamGroupType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'fileContent' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("sourceFileList"); + // we only expect one such element! + if (nl.getLength() == 1) { + sourceFileList = new SourceFileListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'sourceFileList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("contact"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getContact().add(new ContactType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the fileContent property. + * + * @return + * possible object is + * {@link ParamGroupType } + * + */ + public ParamGroupType getFileContent() { + return fileContent; + } + + /** + * Sets the value of the fileContent property. + * + * @param value + * allowed object is + * {@link ParamGroupType } + * + */ + public void setFileContent(ParamGroupType value) { + this.fileContent = value; + } + + /** + * Gets the value of the sourceFileList property. + * + * @return + * possible object is + * {@link SourceFileListType } + * + */ + public SourceFileListType getSourceFileList() { + return sourceFileList; + } + + /** + * Sets the value of the sourceFileList property. + * + * @param value + * allowed object is + * {@link SourceFileListType } + * + */ + public void setSourceFileList(SourceFileListType value) { + this.sourceFileList = value; + } + + /** + * Gets the value of the contact property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the contact property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getContact().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ContactType } + * + * + */ + public List getContact() { + if (contact == null) { + contact = new ArrayList(); + } + return this.contact; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentListType.java new file mode 100644 index 0000000..ff62e5a --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of instruments. + * + *

Java class for InstrumentListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="InstrumentListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="instrument" type="{http://psi.hupo.org/schema_revision/mzML_0.93}InstrumentType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstrumentListType", propOrder = { + "instrument" +}) +public class InstrumentListType { + + @XmlElement(required = true) + protected List instrument; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "instrumentList"; + + public InstrumentListType() {} + + public InstrumentListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public InstrumentListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("instrument"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getInstrument().add(new InstrumentType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the instrument property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the instrument property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getInstrument().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link InstrumentType } + * + * + */ + public List getInstrument() { + if (instrument == null) { + instrument = new ArrayList(); + } + return this.instrument; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentSoftwareRefType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentSoftwareRefType.java new file mode 100644 index 0000000..3d758d5 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentSoftwareRefType.java @@ -0,0 +1,130 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + *

Java class for InstrumentSoftwareRefType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="InstrumentSoftwareRefType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="ref" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstrumentSoftwareRefType") +public class InstrumentSoftwareRefType { + + @XmlAttribute(required = true) + protected String ref; + + + private String elementName = "instrumentSoftwareRef"; + + public InstrumentSoftwareRefType() {} + + public InstrumentSoftwareRefType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public InstrumentSoftwareRefType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String ref = ele.getAttribute("ref"); + if (!ref.equals("")) { // getAttribute returns empty String if no value was specified + setRef(ref); + } + // load elements + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the ref property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRef() { + return ref; + } + + /** + * Sets the value of the ref property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRef(String value) { + this.ref = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentType.java new file mode 100644 index 0000000..e56b8cb --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/InstrumentType.java @@ -0,0 +1,208 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Description of the components of the mass spectrometer used + * + *

Java class for InstrumentType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="InstrumentType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <sequence>
+ *         <element name="componentList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ComponentListType"/>
+ *         <element name="instrumentSoftwareRef" type="{http://psi.hupo.org/schema_revision/mzML_0.93}InstrumentSoftwareRefType" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstrumentType", propOrder = { + "componentList", + "instrumentSoftwareRef" +}) +public class InstrumentType + extends ParamGroupType +{ + + @XmlElement(required = true) + protected ComponentListType componentList; + protected InstrumentSoftwareRefType instrumentSoftwareRef; + @XmlAttribute(required = true) + protected String id; + + + private String elementName = "instrument"; + + public InstrumentType() {} + + public InstrumentType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public InstrumentType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + // load elements + NodeList nl = ele.getElementsByTagName("componentList"); + // we only expect one such element! + if (nl.getLength() == 1) { + componentList = new ComponentListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'componentList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("instrumentSoftwareRef"); + if (nl.getLength() == 1) { + instrumentSoftwareRef = new InstrumentSoftwareRefType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'instrumentSoftwareRef' element, but found: " + nl.getLength()); + } + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the componentList property. + * + * @return + * possible object is + * {@link ComponentListType } + * + */ + public ComponentListType getComponentList() { + return componentList; + } + + /** + * Sets the value of the componentList property. + * + * @param value + * allowed object is + * {@link ComponentListType } + * + */ + public void setComponentList(ComponentListType value) { + this.componentList = value; + } + + /** + * Gets the value of the instrumentSoftwareRef property. + * + * @return + * possible object is + * {@link InstrumentSoftwareRefType } + * + */ + public InstrumentSoftwareRefType getInstrumentSoftwareRef() { + return instrumentSoftwareRef; + } + + /** + * Sets the value of the instrumentSoftwareRef property. + * + * @param value + * allowed object is + * {@link InstrumentSoftwareRefType } + * + */ + public void setInstrumentSoftwareRef(InstrumentSoftwareRefType value) { + this.instrumentSoftwareRef = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/MzMLType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/MzMLType.java new file mode 100644 index 0000000..04bd989 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/MzMLType.java @@ -0,0 +1,476 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * This schema can capture the use of a mass spectrometer, the data generated, and the initial processing of that data (to the level of the peak list). Peak lists are processed data from a mass spectrometry experiment. There can be multiple peak lists in an mzML file, which might be related via a separation, or just in sequence from an automated run. Any one peak list (mass spectrum) may also be composed of a number of acquisitions, which can be described individually herein. + * + *

Java class for mzMLType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="mzMLType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="fileDescription" type="{http://psi.hupo.org/schema_revision/mzML_0.93}FileDescriptionType"/>
+ *         <element name="cvList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVListType"/>
+ *         <element name="referenceableParamGroupList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ReferenceableParamGroupListType" minOccurs="0"/>
+ *         <element name="sampleList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SampleListType" minOccurs="0"/>
+ *         <element name="instrumentList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}InstrumentListType"/>
+ *         <element name="softwareList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SoftwareListType"/>
+ *         <element name="dataProcessingList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}DataProcessingListType"/>
+ *         <element name="run" type="{http://psi.hupo.org/schema_revision/mzML_0.93}RunType"/>
+ *       </sequence>
+ *       <attribute name="accession" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "mzMLType", propOrder = { + "fileDescription", + "cvList", + "referenceableParamGroupList", + "sampleList", + "instrumentList", + "softwareList", + "dataProcessingList", + "run" +}) +public class MzMLType { + + @XmlElement(required = true) + protected FileDescriptionType fileDescription; + @XmlElement(required = true) + protected CVListType cvList; + protected ReferenceableParamGroupListType referenceableParamGroupList; + protected SampleListType sampleList; + @XmlElement(required = true) + protected InstrumentListType instrumentList; + @XmlElement(required = true) + protected SoftwareListType softwareList; + @XmlElement(required = true) + protected DataProcessingListType dataProcessingList; + @XmlElement(required = true) + protected RunType run; + @XmlAttribute + protected String accession; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected String version; + + + private String elementName = "mzML"; + + public MzMLType() {} + + public MzMLType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public MzMLType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String accession = ele.getAttribute("accession"); + if (!accession.equals("")) { // getAttribute returns empty String if no value was specified + setAccession(accession); + } + String version = ele.getAttribute("version"); + if (!version.equals("")) { // getAttribute returns empty String if no value was specified + setVersion(version); + } + // load elements + NodeList nl = ele.getElementsByTagName("fileDescription"); + // we only expect one such element! + if (nl.getLength() == 1) { + fileDescription = new FileDescriptionType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'fileDescription' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("cvList"); + if (nl.getLength() == 1) { + cvList = new CVListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'cvList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("referenceableParamGroupList"); + if (nl.getLength() == 1) { + referenceableParamGroupList = new ReferenceableParamGroupListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'referenceableParamGroupList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("sampleList"); + if (nl.getLength() == 1) { + sampleList = new SampleListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'sampleList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("instrumentList"); + if (nl.getLength() == 1) { + instrumentList = new InstrumentListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'instrumentList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("softwareList"); + if (nl.getLength() == 1) { + softwareList = new SoftwareListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'softwareList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("dataProcessingList"); + if (nl.getLength() == 1) { + dataProcessingList = new DataProcessingListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'dataProcessingList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("run"); + if (nl.getLength() == 1) { + run = new RunType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'run' element, but found: " + nl.getLength()); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the fileDescription property. + * + * @return + * possible object is + * {@link FileDescriptionType } + * + */ + public FileDescriptionType getFileDescription() { + return fileDescription; + } + + /** + * Sets the value of the fileDescription property. + * + * @param value + * allowed object is + * {@link FileDescriptionType } + * + */ + public void setFileDescription(FileDescriptionType value) { + this.fileDescription = value; + } + + /** + * Gets the value of the cvList property. + * + * @return + * possible object is + * {@link CVListType } + * + */ + public CVListType getCvList() { + return cvList; + } + + /** + * Sets the value of the cvList property. + * + * @param value + * allowed object is + * {@link CVListType } + * + */ + public void setCvList(CVListType value) { + this.cvList = value; + } + + /** + * Gets the value of the referenceableParamGroupList property. + * + * @return + * possible object is + * {@link ReferenceableParamGroupListType } + * + */ + public ReferenceableParamGroupListType getReferenceableParamGroupList() { + return referenceableParamGroupList; + } + + /** + * Sets the value of the referenceableParamGroupList property. + * + * @param value + * allowed object is + * {@link ReferenceableParamGroupListType } + * + */ + public void setReferenceableParamGroupList(ReferenceableParamGroupListType value) { + this.referenceableParamGroupList = value; + } + + /** + * Gets the value of the sampleList property. + * + * @return + * possible object is + * {@link SampleListType } + * + */ + public SampleListType getSampleList() { + return sampleList; + } + + /** + * Sets the value of the sampleList property. + * + * @param value + * allowed object is + * {@link SampleListType } + * + */ + public void setSampleList(SampleListType value) { + this.sampleList = value; + } + + /** + * Gets the value of the instrumentList property. + * + * @return + * possible object is + * {@link InstrumentListType } + * + */ + public InstrumentListType getInstrumentList() { + return instrumentList; + } + + /** + * Sets the value of the instrumentList property. + * + * @param value + * allowed object is + * {@link InstrumentListType } + * + */ + public void setInstrumentList(InstrumentListType value) { + this.instrumentList = value; + } + + /** + * Gets the value of the softwareList property. + * + * @return + * possible object is + * {@link SoftwareListType } + * + */ + public SoftwareListType getSoftwareList() { + return softwareList; + } + + /** + * Sets the value of the softwareList property. + * + * @param value + * allowed object is + * {@link SoftwareListType } + * + */ + public void setSoftwareList(SoftwareListType value) { + this.softwareList = value; + } + + /** + * Gets the value of the dataProcessingList property. + * + * @return + * possible object is + * {@link DataProcessingListType } + * + */ + public DataProcessingListType getDataProcessingList() { + return dataProcessingList; + } + + /** + * Sets the value of the dataProcessingList property. + * + * @param value + * allowed object is + * {@link DataProcessingListType } + * + */ + public void setDataProcessingList(DataProcessingListType value) { + this.dataProcessingList = value; + } + + /** + * Gets the value of the run property. + * + * @return + * possible object is + * {@link RunType } + * + */ + public RunType getRun() { + return run; + } + + /** + * Sets the value of the run property. + * + * @param value + * allowed object is + * {@link RunType } + * + */ + public void setRun(RunType value) { + this.run = value; + } + + /** + * Gets the value of the accession property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAccession() { + return accession; + } + + /** + * Sets the value of the accession property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAccession(String value) { + this.accession = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ObjectFactory.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ObjectFactory.java new file mode 100644 index 0000000..c426dc4 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ObjectFactory.java @@ -0,0 +1,426 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the psidev.psi.ms.mzml.mapping.jaxb package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _MzML_QNAME = new QName("http://psi.hupo.org/schema_revision/mzML_0.93", "mzML"); + private final static QName _ComponentListTypeSource_QNAME = new QName("http://psi.hupo.org/schema_revision/mzML_0.93", "source"); + private final static QName _ComponentListTypeAnalyzer_QNAME = new QName("http://psi.hupo.org/schema_revision/mzML_0.93", "analyzer"); + private final static QName _ComponentListTypeDetector_QNAME = new QName("http://psi.hupo.org/schema_revision/mzML_0.93", "detector"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: psidev.psi.ms.mzml.mapping.jaxb + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RunType.SourceFileRefList.SourceFileRef } + * + */ + public RunType.SourceFileRefList.SourceFileRef createRunTypeSourceFileRefListSourceFileRef() { + return new RunType.SourceFileRefList.SourceFileRef(); + } + + /** + * Create an instance of {@link InstrumentSoftwareRefType } + * + */ + public InstrumentSoftwareRefType createInstrumentSoftwareRefType() { + return new InstrumentSoftwareRefType(); + } + + /** + * Create an instance of {@link SpectrumDescriptionType.Scan.SelectionWindowList } + * + */ + public SpectrumDescriptionType.Scan.SelectionWindowList createSpectrumDescriptionTypeScanSelectionWindowList() { + return new SpectrumDescriptionType.Scan.SelectionWindowList(); + } + + /** + * Create an instance of {@link SampleType } + * + */ + public SampleType createSampleType() { + return new SampleType(); + } + + /** + * Create an instance of {@link AcquisitionListType } + * + */ + public AcquisitionListType createAcquisitionListType() { + return new AcquisitionListType(); + } + + /** + * Create an instance of {@link DataProcessingType.ProcessingMethod } + * + */ + public DataProcessingType.ProcessingMethod createDataProcessingTypeProcessingMethod() { + return new DataProcessingType.ProcessingMethod(); + } + + /** + * Create an instance of {@link InstrumentListType } + * + */ + public InstrumentListType createInstrumentListType() { + return new InstrumentListType(); + } + + /** + * Create an instance of {@link CVListType } + * + */ + public CVListType createCVListType() { + return new CVListType(); + } + + /** + * Create an instance of {@link ParamGroupRefType } + * + */ + public ParamGroupRefType createParamGroupRefType() { + return new ParamGroupRefType(); + } + + /** + * Create an instance of {@link CVParamType } + * + */ + public CVParamType createCVParamType() { + return new CVParamType(); + } + + /** + * Create an instance of {@link ComponentType } + * + */ + public ComponentType createComponentType() { + return new ComponentType(); + } + + /** + * Create an instance of {@link ReferenceableParamGroupListType } + * + */ + public ReferenceableParamGroupListType createReferenceableParamGroupListType() { + return new ReferenceableParamGroupListType(); + } + + /** + * Create an instance of {@link SourceFileType } + * + */ + public SourceFileType createSourceFileType() { + return new SourceFileType(); + } + + /** + * Create an instance of {@link ComponentListType } + * + */ + public ComponentListType createComponentListType() { + return new ComponentListType(); + } + + /** + * Create an instance of {@link ReferenceableParamGroupType } + * + */ + public ReferenceableParamGroupType createReferenceableParamGroupType() { + return new ReferenceableParamGroupType(); + } + + /** + * Create an instance of {@link DataProcessingType } + * + */ + public DataProcessingType createDataProcessingType() { + return new DataProcessingType(); + } + + /** + * Create an instance of {@link FileDescriptionType } + * + */ + public FileDescriptionType createFileDescriptionType() { + return new FileDescriptionType(); + } + + /** + * Create an instance of {@link SoftwareType } + * + */ + public SoftwareType createSoftwareType() { + return new SoftwareType(); + } + + /** + * Create an instance of {@link AcquisitionType } + * + */ + public AcquisitionType createAcquisitionType() { + return new AcquisitionType(); + } + + /** + * Create an instance of {@link CVType } + * + */ + public CVType createCVType() { + return new CVType(); + } + + /** + * Create an instance of {@link MzMLType } + * + */ + public MzMLType createMzMLType() { + return new MzMLType(); + } + + /** + * Create an instance of {@link SpectrumDescriptionType.Scan } + * + */ + public SpectrumDescriptionType.Scan createSpectrumDescriptionTypeScan() { + return new SpectrumDescriptionType.Scan(); + } + + /** + * Create an instance of {@link SpectrumType } + * + */ + public SpectrumType createSpectrumType() { + return new SpectrumType(); + } + + /** + * Create an instance of {@link SampleListType } + * + */ + public SampleListType createSampleListType() { + return new SampleListType(); + } + + /** + * Create an instance of {@link ScanType } + * + */ + public ScanType createScanType() { + return new ScanType(); + } + + /** + * Create an instance of {@link SoftwareListType.Software } + * + */ + public SoftwareListType.Software createSoftwareListTypeSoftware() { + return new SoftwareListType.Software(); + } + + /** + * Create an instance of {@link SourceFileListType } + * + */ + public SourceFileListType createSourceFileListType() { + return new SourceFileListType(); + } + + /** + * Create an instance of {@link SoftwareListType.Software.SoftwareParam } + * + */ + public SoftwareListType.Software.SoftwareParam createSoftwareListTypeSoftwareSoftwareParam() { + return new SoftwareListType.Software.SoftwareParam(); + } + + /** + * Create an instance of {@link FileChecksumType } + * + */ + public FileChecksumType createFileChecksumType() { + return new FileChecksumType(); + } + + /** + * Create an instance of {@link SpectrumListType } + * + */ + public SpectrumListType createSpectrumListType() { + return new SpectrumListType(); + } + + /** + * Create an instance of {@link SpectrumDescriptionType } + * + */ + public SpectrumDescriptionType createSpectrumDescriptionType() { + return new SpectrumDescriptionType(); + } + + /** + * Create an instance of {@link PrecursorListType } + * + */ + public PrecursorListType createPrecursorListType() { + return new PrecursorListType(); + } + + /** + * Create an instance of {@link DataProcessingListType } + * + */ + public DataProcessingListType createDataProcessingListType() { + return new DataProcessingListType(); + } + + /** + * Create an instance of {@link PrecursorType } + * + */ + public PrecursorType createPrecursorType() { + return new PrecursorType(); + } + + /** + * Create an instance of {@link ContactType } + * + */ + public ContactType createContactType() { + return new ContactType(); + } + + /** + * Create an instance of {@link BinaryDataArrayType } + * + */ + public BinaryDataArrayType createBinaryDataArrayType() { + return new BinaryDataArrayType(); + } + + /** + * Create an instance of {@link RunType } + * + */ + public RunType createRunType() { + return new RunType(); + } + + /** + * Create an instance of {@link UserParamType } + * + */ + public UserParamType createUserParamType() { + return new UserParamType(); + } + + /** + * Create an instance of {@link RunType.SourceFileRefList } + * + */ + public RunType.SourceFileRefList createRunTypeSourceFileRefList() { + return new RunType.SourceFileRefList(); + } + + /** + * Create an instance of {@link SpectrumDescriptionType.Scan.SelectionWindowList.SelectionWindow } + * + */ + public SpectrumDescriptionType.Scan.SelectionWindowList.SelectionWindow createSpectrumDescriptionTypeScanSelectionWindowListSelectionWindow() { + return new SpectrumDescriptionType.Scan.SelectionWindowList.SelectionWindow(); + } + + /** + * Create an instance of {@link ParamGroupType } + * + */ + public ParamGroupType createParamGroupType() { + return new ParamGroupType(); + } + + /** + * Create an instance of {@link InstrumentType } + * + */ + public InstrumentType createInstrumentType() { + return new InstrumentType(); + } + + /** + * Create an instance of {@link SoftwareListType } + * + */ + public SoftwareListType createSoftwareListType() { + return new SoftwareListType(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link MzMLType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", name = "mzML") + public JAXBElement createMzML(MzMLType value) { + return new JAXBElement(_MzML_QNAME, MzMLType.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ComponentType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", name = "source", scope = ComponentListType.class) + public JAXBElement createComponentListTypeSource(ComponentType value) { + return new JAXBElement(_ComponentListTypeSource_QNAME, ComponentType.class, ComponentListType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ComponentType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", name = "analyzer", scope = ComponentListType.class) + public JAXBElement createComponentListTypeAnalyzer(ComponentType value) { + return new JAXBElement(_ComponentListTypeAnalyzer_QNAME, ComponentType.class, ComponentListType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ComponentType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", name = "detector", scope = ComponentListType.class) + public JAXBElement createComponentListTypeDetector(ComponentType value) { + return new JAXBElement(_ComponentListTypeDetector_QNAME, ComponentType.class, ComponentListType.class, value); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupRefType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupRefType.java new file mode 100644 index 0000000..93129a0 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupRefType.java @@ -0,0 +1,182 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; + + +/** + *

Java class for ParamGroupRefType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ParamGroupRefType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="ref" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ParamGroupRefType") +public class ParamGroupRefType { + + @XmlAttribute(required = true) + protected String ref; + + private static HashMap refs = refs = new HashMap(); + + private String elementName = "paramGroupRef"; + + public ParamGroupRefType() { + } + + public static void addParamGroup(String aRef, ReferenceableParamGroupType aPGRT) { + refs.put(aRef, aPGRT); + } + + public static List getCVParams(Element element) { + List result = new ArrayList(); + String ref = element.getAttribute("ref"); + if (ref.equals("")) { // getAttribute returns empty String if no value was specified + // Schema is incorrect! + throw new IllegalArgumentException("Element '" + element.getLocalName() + "' should contain a 'ref' attribute, but it was absent or empty! Please validate this file against its schema first!"); + } + + ParamGroupType pgt = refs.get(ref); + if(pgt == null || (pgt.getCvParam().size() == 0 && pgt.getUserParam().size() == 0)) { + throw new IllegalArgumentException("Element '" + element.getLocalName() + "' should reference a known ReferenceableParamGroup, with id '" + ref + "', but it was not found in memory. Try parsing the ReferenceableParamGroupList first, or check for inconsistencies in the references first!"); + } + + result = pgt.getCvParam(); + + return result; + } + + public static List getUserParams(Element element) { + List result = new ArrayList(); + String ref = element.getAttribute("ref"); + if (!ref.equals("")) { // getAttribute returns empty String if no value was specified + // Error condition!! + } + + ParamGroupType pgt = refs.get(ref); + + result = pgt.getUserParam(); + + return result; + } + + + public ParamGroupRefType(String xmlSnippet) { + if (refs == null) { + refs = new HashMap(); + } + parseXml(xmlSnippet); + } + + public ParamGroupRefType(Element element) { + if (refs == null) { + refs = new HashMap(); + } + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String ref = ele.getAttribute("ref"); + if (!ref.equals("")) { // getAttribute returns empty String if no value was specified + setRef(ref); + } + // load elements + + } + } + + public void loadRef(String id, ParamGroupType paramGroup) { + refs.put(id, paramGroup); + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the ref property. + * + * @return + * possible object is + * {@link String } + * + */ + public ParamGroupType getRef() { + return refs.get(ref); + } + + /** + * Sets the value of the ref property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRef(String value) { + this.ref = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupType.java new file mode 100644 index 0000000..bceb5ea --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ParamGroupType.java @@ -0,0 +1,241 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * Structure allowing the use of a controlled (cvParam) or uncontrolled vocabulary (userParam), or a reference to a predefined set of these in this mzML file (paramGroupRef). + * + *

Java class for ParamGroupType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ParamGroupType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="paramGroupRef" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupRefType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="cvParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVParamType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="userParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}UserParamType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ParamGroupType", propOrder = { + "paramGroupRef", + "cvParam", + "userParam" +}) +public class ParamGroupType { + + @XmlElement(required = true) + protected List paramGroupRef; + @XmlElement(required = true) + protected List cvParam; + @XmlElement(required = true) + protected List userParam; + + + private String elementName1 = "ionSelection"; + private String elementName2 = "activation"; + private String elementName3 = "fileContent"; + + public ParamGroupType() {} + + public ParamGroupType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ParamGroupType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + // different element names for same type! + NodeList nl = document.getElementsByTagName(elementName1); + if (nl.getLength() == 0) { // if this element name did not match, try the next + nl = document.getElementsByTagName(elementName2); + } + if (nl.getLength() == 0) { // if this element name did not match, try the next + nl = document.getElementsByTagName(elementName3); + } + if (nl.getLength() == 1) { // we found one element! now we can create the Object + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected one '" + elementName1 + "' element " + + "or one '" + elementName2 + "' element " + + "or one '" + elementName3 + "' element " + + ", but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // load elements + NodeList nl = ele.getElementsByTagName("paramGroupRef"); + // we only expect one such element! + for ( int i = 0; i < nl.getLength(); i++ ) { + Element e = (Element) nl.item(i); + if(e.getParentNode().isSameNode(ele)) { + this.getCvParam().addAll(ParamGroupRefType.getCVParams(e)); + this.getUserParam().addAll(ParamGroupRefType.getUserParams(e)); + } + } + nl = null; + nl = ele.getElementsByTagName("cvParam"); + for ( int i = 0; i < nl.getLength(); i++ ) { + Element e = (Element) nl.item(i); + if(e.getParentNode().isSameNode(ele)) { + this.getCvParam().add(new CVParamType(e)); + } + } + nl = null; + nl = ele.getElementsByTagName("userParam"); + for ( int i = 0; i < nl.getLength(); i++ ) { + Element e = (Element) nl.item(i); + if(e.getParentNode().isSameNode(ele)) { + this.getUserParam().add(new UserParamType(e)); + } + } + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the paramGroupRef property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the paramGroupRef property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getParamGroupRef().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ParamGroupRefType } + * + * + */ + public List getParamGroupRef() { + if (paramGroupRef == null) { + paramGroupRef = new ArrayList(); + } + return this.paramGroupRef; + } + + /** + * Gets the value of the cvParam property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvParam property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvParam().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CVParamType } + * + * + */ + public List getCvParam() { + if (cvParam == null) { + cvParam = new ArrayList(); + } + return this.cvParam; + } + + /** + * Gets the value of the userParam property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the userParam property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getUserParam().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link UserParamType } + * + * + */ + public List getUserParam() { + if (userParam == null) { + userParam = new ArrayList(); + } + return this.userParam; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorListType.java new file mode 100644 index 0000000..c6ccb31 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorListType.java @@ -0,0 +1,176 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of precursors to the spectrum currently being described. + * + *

Java class for PrecursorListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PrecursorListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="precursor" type="{http://psi.hupo.org/schema_revision/mzML_0.93}PrecursorType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PrecursorListType", propOrder = { + "precursor" +}) +public class PrecursorListType { + + @XmlElement(required = true) + protected List precursor; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "precursorList"; + + public PrecursorListType() {} + + public PrecursorListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public PrecursorListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // create other elements + NodeList nl = ele.getElementsByTagName("precursor"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getPrecursor().add(new PrecursorType((Element) nl.item(i))); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the precursor property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the precursor property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getPrecursor().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link PrecursorType } + * + * + */ + public List getPrecursor() { + if (precursor == null) { + precursor = new ArrayList(); + } + return this.precursor; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorType.java new file mode 100644 index 0000000..40b87a2 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/PrecursorType.java @@ -0,0 +1,208 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * The method of precursor ion selection and activation + * + *

Java class for PrecursorType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PrecursorType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="ionSelection" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType"/>
+ *         <element name="activation" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType"/>
+ *       </sequence>
+ *       <attribute name="spectrumRef" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PrecursorType", propOrder = { + "ionSelection", + "activation" +}) +public class PrecursorType { + + @XmlElement(required = true) + protected ParamGroupType ionSelection; + @XmlElement(required = true) + protected ParamGroupType activation; + @XmlAttribute + protected String spectrumRef; + + + private String elementName = "precursor"; + + public PrecursorType() {} + + public PrecursorType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public PrecursorType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String spectrumRef = ele.getAttribute("spectrumRef"); + if (!spectrumRef.equals("")) { // getAttribute returns empty String if no value was specified + setSpectrumRef(spectrumRef); + } + + // create other elements + NodeList nl = ele.getElementsByTagName("ionSelection"); + // we only expect one such element! + if (nl.getLength() == 1) { + ionSelection = new ParamGroupType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'ionSelection' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("activation"); + // we only expect one such element! + if (nl.getLength() == 1) { + activation = new ParamGroupType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'activation' element, but found: " + nl.getLength()); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the ionSelection property. + * + * @return + * possible object is + * {@link ParamGroupType } + * + */ + public ParamGroupType getIonSelection() { + return ionSelection; + } + + /** + * Sets the value of the ionSelection property. + * + * @param value + * allowed object is + * {@link ParamGroupType } + * + */ + public void setIonSelection(ParamGroupType value) { + this.ionSelection = value; + } + + /** + * Gets the value of the activation property. + * + * @return + * possible object is + * {@link ParamGroupType } + * + */ + public ParamGroupType getActivation() { + return activation; + } + + /** + * Sets the value of the activation property. + * + * @param value + * allowed object is + * {@link ParamGroupType } + * + */ + public void setActivation(ParamGroupType value) { + this.activation = value; + } + + /** + * Gets the value of the spectrumRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSpectrumRef() { + return spectrumRef; + } + + /** + * Sets the value of the spectrumRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSpectrumRef(String value) { + this.spectrumRef = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupListType.java new file mode 100644 index 0000000..5fd16c2 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of ReferenceableParamGroups + * + *

Java class for ReferenceableParamGroupListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ReferenceableParamGroupListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="referenceableParamGroup" type="{http://psi.hupo.org/schema_revision/mzML_0.93}ReferenceableParamGroupType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ReferenceableParamGroupListType", propOrder = { + "referenceableParamGroup" +}) +public class ReferenceableParamGroupListType { + + @XmlElement(required = true) + protected List referenceableParamGroup; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "referenceableParamGroupList"; + + public ReferenceableParamGroupListType() {} + + public ReferenceableParamGroupListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ReferenceableParamGroupListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("referenceableParamGroup"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getReferenceableParamGroup().add(new ReferenceableParamGroupType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the referenceableParamGroup property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the referenceableParamGroup property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReferenceableParamGroup().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ReferenceableParamGroupType } + * + * + */ + public List getReferenceableParamGroup() { + if (referenceableParamGroup == null) { + referenceableParamGroup = new ArrayList(); + } + return this.referenceableParamGroup; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupType.java new file mode 100644 index 0000000..16f47d9 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ReferenceableParamGroupType.java @@ -0,0 +1,138 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * ParamGroup that can be referenced from elsewhere in this mzML document by using the 'paramGroupRef' element in that location to reference the 'id' attribute value of this element. + * + *

Java class for ReferenceableParamGroupType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ReferenceableParamGroupType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ReferenceableParamGroupType") +public class ReferenceableParamGroupType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected String id; + + + private String elementName = "referenceableParamGroup"; + + public ReferenceableParamGroupType() {} + + public ReferenceableParamGroupType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public ReferenceableParamGroupType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + // load elements + // inherited form ParamGroupType + super.create(node); + // Now add this referenceable param group to the HashMap of + // ParamGroupRefType + ParamGroupRefType.addParamGroup(id, this); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/RunType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/RunType.java new file mode 100644 index 0000000..e898aa2 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/RunType.java @@ -0,0 +1,591 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.bind.annotation.*; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + + +/** + *

Java class for RunType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RunType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <sequence>
+ *         <element name="sourceFileRefList" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="sourceFileRef" maxOccurs="unbounded" minOccurs="0">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="ref" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="count" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="spectrumList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SpectrumListType"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="instrumentRef" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="sampleRef" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="timeStamp" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RunType", propOrder = { + "sourceFileRefList", + "spectrumList" +}) +public class RunType + extends ParamGroupType +{ + + protected RunType.SourceFileRefList sourceFileRefList; + @XmlElement(required = true) + protected SpectrumListType spectrumList; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected String instrumentRef; + @XmlAttribute + protected String sampleRef; + @XmlAttribute + protected XMLGregorianCalendar timeStamp; + + + private String elementName = "run"; + + public RunType() {} + + public RunType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public RunType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String instrumentRef = ele.getAttribute("instrumentRef"); + if (!instrumentRef.equals("")) { // getAttribute returns empty String if no value was specified + setInstrumentRef(instrumentRef); + } + String sampleRef = ele.getAttribute("sampleRef"); + if (!sampleRef.equals("")) { // getAttribute returns empty String if no value was specified + setSampleRef(sampleRef); + } + String timeStamp = ele.getAttribute("timeStamp"); + if (!timeStamp.equals("")) { // getAttribute returns empty String if no value was specified + try { + setTimeStamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(timeStamp)); + } catch (DatatypeConfigurationException e) { + throw new IllegalStateException("Could not create a XMLGregorianCalendar " + + "from String representation: " + timeStamp, e); + } + } + // load elements + NodeList nl = ele.getElementsByTagName("spectrumList"); + // we only expect one such element! + if (nl.getLength() == 1) { + spectrumList = new SpectrumListType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'spectrumList' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("sourceFileRefList"); + // we only expect one such element! + if (nl.getLength() == 1) { + sourceFileRefList = new SourceFileRefList((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'sourceFileRefList' element, but found: " + nl.getLength()); + } + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the sourceFileRefList property. + * + * @return + * possible object is + * {@link RunType.SourceFileRefList } + * + */ + public RunType.SourceFileRefList getSourceFileRefList() { + return sourceFileRefList; + } + + /** + * Sets the value of the sourceFileRefList property. + * + * @param value + * allowed object is + * {@link RunType.SourceFileRefList } + * + */ + public void setSourceFileRefList(RunType.SourceFileRefList value) { + this.sourceFileRefList = value; + } + + /** + * Gets the value of the spectrumList property. + * + * @return + * possible object is + * {@link SpectrumListType } + * + */ + public SpectrumListType getSpectrumList() { + return spectrumList; + } + + /** + * Sets the value of the spectrumList property. + * + * @param value + * allowed object is + * {@link SpectrumListType } + * + */ + public void setSpectrumList(SpectrumListType value) { + this.spectrumList = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the instrumentRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getInstrumentRef() { + return instrumentRef; + } + + /** + * Sets the value of the instrumentRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setInstrumentRef(String value) { + this.instrumentRef = value; + } + + /** + * Gets the value of the sampleRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSampleRef() { + return sampleRef; + } + + /** + * Sets the value of the sampleRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSampleRef(String value) { + this.sampleRef = value; + } + + /** + * Gets the value of the timeStamp property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getTimeStamp() { + return timeStamp; + } + + /** + * Sets the value of the timeStamp property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setTimeStamp(XMLGregorianCalendar value) { + this.timeStamp = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="sourceFileRef" maxOccurs="unbounded" minOccurs="0">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="ref" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *       <attribute name="count" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "sourceFileRef" + }) + public static class SourceFileRefList { + + @XmlElement(required = true) + protected List sourceFileRef; + @XmlAttribute + protected BigInteger count; + + + private String elementName = "sourceFileRefList"; + + public SourceFileRefList() {} + + public SourceFileRefList(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SourceFileRefList(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("sourceFileRef"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSourceFileRef().add(new SourceFileRef((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the sourceFileRef property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the sourceFileRef property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getSourceFileRef().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link RunType.SourceFileRefList.SourceFileRef } + * + * + */ + public List getSourceFileRef() { + if (sourceFileRef == null) { + sourceFileRef = new ArrayList(); + } + return this.sourceFileRef; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="ref" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class SourceFileRef { + + @XmlAttribute + protected String ref; + + + private String elementName = "sourceFileRef"; + + public SourceFileRef() {} + + public SourceFileRef(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SourceFileRef(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String ref = ele.getAttribute("ref"); + if (!ref.equals("")) { // getAttribute returns empty String if no value was specified + setRef(ref); + } + // load elements + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the ref property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRef() { + return ref; + } + + /** + * Sets the value of the ref property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRef(String value) { + this.ref = value; + } + + } + + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleListType.java new file mode 100644 index 0000000..6d23fde --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of samples. + * + *

Java class for SampleListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SampleListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="sample" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SampleType" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SampleListType", propOrder = { + "sample" +}) +public class SampleListType { + + @XmlElement(required = true) + protected List sample; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "sampleList"; + + public SampleListType() {} + + public SampleListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SampleListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("sample"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSample().add(new SampleType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the sample property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the sample property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getSample().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SampleType } + * + * + */ + public List getSample() { + if (sample == null) { + sample = new ArrayList(); + } + return this.sample; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleType.java new file mode 100644 index 0000000..4365106 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SampleType.java @@ -0,0 +1,166 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Expansible description of the sample used to generate the dataset, named in sampleName. + * + *

Java class for SampleType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SampleType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SampleType") +public class SampleType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected String id; + @XmlAttribute + protected String name; + + + private String elementName = "sample"; + + public SampleType() {} + + public SampleType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SampleType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String name = ele.getAttribute("name"); + if (!name.equals("")) { // getAttribute returns empty String if no value was specified + setName(name); + } + // load elements + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ScanType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ScanType.java new file mode 100644 index 0000000..7ed64c8 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/ScanType.java @@ -0,0 +1,82 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Node; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + * The instrument's 'run time' parameters; common to the whole of this spectrum. + * + *

Java class for ScanType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ScanType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <attribute name="instrumentRef" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ScanType") +public class ScanType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected String instrumentRef; + + + protected void create(Node node) { + if (node != null) { + super.create(node); + } + } + + + + /** + * Gets the value of the instrumentRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getInstrumentRef() { + return instrumentRef; + } + + /** + * Sets the value of the instrumentRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setInstrumentRef(String value) { + this.instrumentRef = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareListType.java new file mode 100644 index 0000000..bdcdb56 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareListType.java @@ -0,0 +1,559 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of software used to acquire and/or process the data in this mzML file. + * + *

Java class for SoftwareListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SoftwareListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="software" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}SoftwareType">
+ *                 <sequence>
+ *                   <element name="softwareParam">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="accession" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="cvLabel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </extension>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SoftwareListType", propOrder = { + "software" +}) +public class SoftwareListType { + + @XmlElement(required = true) + protected List software; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "softwareList"; + + public SoftwareListType() {} + + public SoftwareListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SoftwareListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("software"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSoftware().add(new Software((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the software property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the software property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getSoftware().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SoftwareListType.Software } + * + * + */ + public List getSoftware() { + if (software == null) { + software = new ArrayList(); + } + return this.software; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}SoftwareType">
+     *       <sequence>
+     *         <element name="softwareParam">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="accession" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="cvLabel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </extension>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "softwareParam" + }) + public static class Software + extends SoftwareType + { + + @XmlElement(required = true) + protected SoftwareListType.Software.SoftwareParam softwareParam; + @XmlAttribute(required = true) + protected String id; + + + private String elementName = "software"; + + public Software() {} + + public Software(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public Software(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + // load elements + NodeList nl = ele.getElementsByTagName("softwareParam"); + // we only expect one such element! + if (nl.getLength() == 1) { + softwareParam = new SoftwareParam((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'softwareParam' element, but found: " + nl.getLength()); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the softwareParam property. + * + * @return + * possible object is + * {@link SoftwareListType.Software.SoftwareParam } + * + */ + public SoftwareListType.Software.SoftwareParam getSoftwareParam() { + return softwareParam; + } + + /** + * Sets the value of the softwareParam property. + * + * @param value + * allowed object is + * {@link SoftwareListType.Software.SoftwareParam } + * + */ + public void setSoftwareParam(SoftwareListType.Software.SoftwareParam value) { + this.softwareParam = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="accession" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="cvLabel" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class SoftwareParam { + + @XmlAttribute(required = true) + protected String accession; + @XmlAttribute(required = true) + protected String cvLabel; + @XmlAttribute(required = true) + protected String name; + @XmlAttribute(required = true) + protected String version; + + + private String elementName = "softwareParam"; + + public SoftwareParam() {} + + public SoftwareParam(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SoftwareParam(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String accession = ele.getAttribute("accession"); + if (!accession.equals("")) { // getAttribute returns empty String if no value was specified + setAccession(accession); + } + String cvLabel = ele.getAttribute("cvLabel"); + if (!cvLabel.equals("")) { // getAttribute returns empty String if no value was specified + setCvLabel(cvLabel); + } + String name = ele.getAttribute("name"); + if (!name.equals("")) { // getAttribute returns empty String if no value was specified + setName(name); + } + String version = ele.getAttribute("version"); + if (!version.equals("")) { // getAttribute returns empty String if no value was specified + setVersion(version); + } + // load elements + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the accession property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAccession() { + return accession; + } + + /** + * Sets the value of the accession property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAccession(String value) { + this.accession = value; + } + + /** + * Gets the value of the cvLabel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCvLabel() { + return cvLabel; + } + + /** + * Sets the value of the cvLabel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCvLabel(String value) { + this.cvLabel = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + + } + + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareType.java new file mode 100644 index 0000000..8380f24 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SoftwareType.java @@ -0,0 +1,39 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + * Software information (the software that produced the peak list). + * + *

Java class for SoftwareType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SoftwareType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SoftwareType") +public class SoftwareType { + + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileListType.java new file mode 100644 index 0000000..e14dcea --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileListType.java @@ -0,0 +1,177 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of source files + * + *

Java class for SourceFileListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SourceFileListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="sourceFile" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SourceFileType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SourceFileListType", propOrder = { + "sourceFile" +}) +public class SourceFileListType { + + @XmlElement(required = true) + protected List sourceFile; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "sourceFileList"; + + public SourceFileListType() {} + + public SourceFileListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SourceFileListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("sourceFile"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSourceFile().add(new SourceFileType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the sourceFile property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the sourceFile property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getSourceFile().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SourceFileType } + * + * + */ + public List getSourceFile() { + if (sourceFile == null) { + sourceFile = new ArrayList(); + } + return this.sourceFile; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileType.java new file mode 100644 index 0000000..682e749 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SourceFileType.java @@ -0,0 +1,238 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Description of the source file, including location and type. + * + *

Java class for SourceFileType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SourceFileType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="fileChecksum" type="{http://psi.hupo.org/schema_revision/mzML_0.93}FileChecksumType"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="sourceFileLocation" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="sourceFileName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="sourceFileType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SourceFileType", propOrder = { + "fileChecksum" +}) +public class SourceFileType + extends ParamGroupType +{ + + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected String sourceFileLocation; + @XmlAttribute(required = true) + protected String sourceFileName; + @XmlAttribute(required = true) + protected String sourceFileType; + + + private String elementName = "sourceFile"; + + public SourceFileType() {} + + public SourceFileType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SourceFileType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String sourceFileLocation = ele.getAttribute("sourceFileLocation"); + if (!sourceFileLocation.equals("")) { // getAttribute returns empty String if no value was specified + setSourceFileLocation(sourceFileLocation); + } + String sourceFileName = ele.getAttribute("sourceFileName"); + if (!sourceFileName.equals("")) { // getAttribute returns empty String if no value was specified + setSourceFileName(sourceFileName); + } + // load elements + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the fileChecksum property. + * + * @return + * possible object is + * {@link FileChecksumType } + * + */ + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the sourceFileLocation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSourceFileLocation() { + return sourceFileLocation; + } + + /** + * Sets the value of the sourceFileLocation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSourceFileLocation(String value) { + this.sourceFileLocation = value; + } + + /** + * Gets the value of the sourceFileName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSourceFileName() { + return sourceFileName; + } + + /** + * Sets the value of the sourceFileName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSourceFileName(String value) { + this.sourceFileName = value; + } + + /** + * Gets the value of the sourceFileType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSourceFileType() { + return sourceFileType; + } + + /** + * Sets the value of the sourceFileType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSourceFileType(String value) { + this.sourceFileType = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumDescriptionType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumDescriptionType.java new file mode 100644 index 0000000..ab65099 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumDescriptionType.java @@ -0,0 +1,651 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.*; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; + + +/** + * Description of the parameters for the mass spectrometer for a given acquisition (or list of acquisitions). + * + *

Java class for SpectrumDescriptionType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SpectrumDescriptionType">
+ *   <complexContent>
+ *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ParamGroupType">
+ *       <sequence>
+ *         <element name="acquisitionList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}AcquisitionListType" minOccurs="0"/>
+ *         <element name="precursorList" type="{http://psi.hupo.org/schema_revision/mzML_0.93}PrecursorListType" minOccurs="0"/>
+ *         <element name="scan" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ScanType">
+ *                 <sequence>
+ *                   <element name="selectionWindowList">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="selectionWindow" maxOccurs="unbounded">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <sequence>
+ *                                       <element name="cvParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVParamType" maxOccurs="unbounded" minOccurs="2"/>
+ *                                     </sequence>
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                           </sequence>
+ *                           <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </extension>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SpectrumDescriptionType", propOrder = { + "acquisitionList", + "precursorList", + "scan" +}) +public class SpectrumDescriptionType + extends ParamGroupType +{ + + protected AcquisitionListType acquisitionList; + protected PrecursorListType precursorList; + protected SpectrumDescriptionType.Scan scan; + + + private String elementName = "spectrumDescription"; + + public SpectrumDescriptionType() {} + + public SpectrumDescriptionType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SpectrumDescriptionType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // no attributes + // load elements + NodeList nl = ele.getElementsByTagName("precursorList"); + // we only expect one such element! + if (nl.getLength() == 1) { + precursorList = new PrecursorListType((Element) nl.item(0)); + } + nl = null; + nl = ele.getElementsByTagName("acquisitionList"); + // we only expect one such element! + if (nl.getLength() == 1) { + acquisitionList = new AcquisitionListType((Element) nl.item(0)); + } + nl = null; + nl = ele.getElementsByTagName("scan"); + // we expect no more than one such element! + if (nl.getLength() == 1) { + scan = new Scan((Element) nl.item(0)); + } else if (nl.getLength()>1){ + throw new IllegalStateException("Expected only one 'scan' element, but found: " + nl.getLength()); + } + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + + /** + * Gets the value of the acquisitionList property. + * + * @return + * possible object is + * {@link AcquisitionListType } + * + */ + public AcquisitionListType getAcquisitionList() { + return acquisitionList; + } + + /** + * Sets the value of the acquisitionList property. + * + * @param value + * allowed object is + * {@link AcquisitionListType } + * + */ + public void setAcquisitionList(AcquisitionListType value) { + this.acquisitionList = value; + } + + /** + * Gets the value of the precursorList property. + * + * @return + * possible object is + * {@link PrecursorListType } + * + */ + public PrecursorListType getPrecursorList() { + return precursorList; + } + + /** + * Sets the value of the precursorList property. + * + * @param value + * allowed object is + * {@link PrecursorListType } + * + */ + public void setPrecursorList(PrecursorListType value) { + this.precursorList = value; + } + + /** + * Gets the value of the scan property. + * + * @return + * possible object is + * {@link SpectrumDescriptionType.Scan } + * + */ + public SpectrumDescriptionType.Scan getScan() { + return scan; + } + + /** + * Sets the value of the scan property. + * + * @param value + * allowed object is + * {@link SpectrumDescriptionType.Scan } + * + */ + public void setScan(SpectrumDescriptionType.Scan value) { + this.scan = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <extension base="{http://psi.hupo.org/schema_revision/mzML_0.93}ScanType">
+     *       <sequence>
+     *         <element name="selectionWindowList">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <sequence>
+     *                   <element name="selectionWindow" maxOccurs="unbounded">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <sequence>
+     *                             <element name="cvParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVParamType" maxOccurs="unbounded" minOccurs="2"/>
+     *                           </sequence>
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                 </sequence>
+     *                 <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *     </extension>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "selectionWindowList" + }) + public static class Scan + extends ScanType + { + + @XmlElement(required = true) + protected SpectrumDescriptionType.Scan.SelectionWindowList selectionWindowList; + + + private String elementName = "scan"; + + public Scan() {} + + public Scan(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public Scan(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // inherited from ScanType + String instrumentRef = ele.getAttribute("instrumentRef"); + if (!instrumentRef.equals("")) { // getAttribute returns empty String if no value was specified + setInstrumentRef(instrumentRef); + } + // load elements + NodeList nl = ele.getElementsByTagName("selectionWindowList"); + // we only expect one such element! + if (nl.getLength() == 1) { + selectionWindowList = new SelectionWindowList((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'selectionWindowList' element, but found: " + nl.getLength()); + } + // inherited form ParamGroupType + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the selectionWindowList property. + * + * @return + * possible object is + * {@link SpectrumDescriptionType.Scan.SelectionWindowList } + * + */ + public SpectrumDescriptionType.Scan.SelectionWindowList getSelectionWindowList() { + return selectionWindowList; + } + + /** + * Sets the value of the selectionWindowList property. + * + * @param value + * allowed object is + * {@link SpectrumDescriptionType.Scan.SelectionWindowList } + * + */ + public void setSelectionWindowList(SpectrumDescriptionType.Scan.SelectionWindowList value) { + this.selectionWindowList = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <sequence>
+         *         <element name="selectionWindow" maxOccurs="unbounded">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <sequence>
+         *                   <element name="cvParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVParamType" maxOccurs="unbounded" minOccurs="2"/>
+         *                 </sequence>
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *       </sequence>
+         *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "selectionWindow" + }) + public static class SelectionWindowList { + + @XmlElement(required = true) + protected List selectionWindow; + @XmlAttribute(required = true) + protected int count; + + + private String elementName = "selectionWindowList"; + + public SelectionWindowList() {} + + public SelectionWindowList(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SelectionWindowList(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(Integer.parseInt(count)); + } + + // load elements + NodeList nl = ele.getElementsByTagName("selectionWindow"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSelectionWindow().add(new SelectionWindow((Element) nl.item(i))); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the selectionWindow property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the selectionWindow property. + * + *

+ * For example, to add a new item, do as follows: + *

+             *    getSelectionWindow().add(newItem);
+             * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SpectrumDescriptionType.Scan.SelectionWindowList.SelectionWindow } + * + * + */ + public List getSelectionWindow() { + if (selectionWindow == null) { + selectionWindow = new ArrayList(); + } + return this.selectionWindow; + } + + /** + * Gets the value of the count property. + * + */ + public int getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + */ + public void setCount(int value) { + this.count = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <sequence>
+             *         <element name="cvParam" type="{http://psi.hupo.org/schema_revision/mzML_0.93}CVParamType" maxOccurs="unbounded" minOccurs="2"/>
+             *       </sequence>
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "cvParam" + }) + public static class SelectionWindow { + + @XmlElement(required = true) + protected List cvParam; + + + private String elementName = "selectionWindow"; + + public SelectionWindow() {} + + public SelectionWindow(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SelectionWindow(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + // create other elements + NodeList nl = ele.getElementsByTagName("cvParam"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getCvParam().add(new CVParamType((Element) nl.item(i))); + } + + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the cvParam property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvParam property. + * + *

+ * For example, to add a new item, do as follows: + *

+                 *    getCvParam().add(newItem);
+                 * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CVParamType } + * + * + */ + public List getCvParam() { + if (cvParam == null) { + cvParam = new ArrayList(); + } + return this.cvParam; + } + + } + + } + + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumListType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumListType.java new file mode 100644 index 0000000..2397738 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumListType.java @@ -0,0 +1,176 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayInputStream; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; + + +/** + * List and descriptions of spectra. + * + *

Java class for SpectrumListType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SpectrumListType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="spectrum" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SpectrumType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="count" use="required" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SpectrumListType", propOrder = { + "spectrum" +}) +public class SpectrumListType { + + @XmlElement(required = true) + protected List spectrum; + @XmlAttribute(required = true) + protected BigInteger count; + + + private String elementName = "spectrumList"; + + public SpectrumListType() {} + + public SpectrumListType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SpectrumListType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String count = ele.getAttribute("count"); + if (!count.equals("")) { // getAttribute returns empty String if no value was specified + setCount(new BigInteger(count)); + } + // load elements + NodeList nl = ele.getElementsByTagName("spectrum"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getSpectrum().add(new SpectrumType((Element) nl.item(i))); + } + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the spectrum property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the spectrum property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getSpectrum().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SpectrumType } + * + * + */ + public List getSpectrum() { + if (spectrum == null) { + spectrum = new ArrayList(); + } + return this.spectrum; + } + + /** + * Gets the value of the count property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getCount() { + return count; + } + + /** + * Sets the value of the count property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setCount(BigInteger value) { + this.count = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumType.java new file mode 100644 index 0000000..c181407 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/SpectrumType.java @@ -0,0 +1,319 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.bind.annotation.*; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.List; + + +/** + * The structure that captures the generation of a peak list (including the underlying acquisitions) + * + *

Java class for SpectrumType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="SpectrumType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="spectrumDescription" type="{http://psi.hupo.org/schema_revision/mzML_0.93}SpectrumDescriptionType"/>
+ *         <element name="binaryDataArray" type="{http://psi.hupo.org/schema_revision/mzML_0.93}BinaryDataArrayType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="dataProcessingRef" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="msLevel" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="scanNumber" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="sourceFileRef" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="spectrumType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SpectrumType", propOrder = { + "spectrumDescription", + "binaryDataArray" +}) +public class SpectrumType extends ParamGroupType { + + @XmlElement(required = true) + protected SpectrumDescriptionType spectrumDescription; + @XmlElement(required = true) + protected List binaryDataArray; + @XmlAttribute + protected String dataProcessingRef; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected int msLevel; + @XmlAttribute(required = true) + protected int scanNumber; + @XmlAttribute + protected String sourceFileRef; + + + + private String elementName = "spectrum"; + + public SpectrumType() {} + + public SpectrumType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public SpectrumType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + protected void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String id = ele.getAttribute("id"); + if (!id.equals("")) { // getAttribute returns empty String if no value was specified + setId(id); + } + String dataProcessingRef = ele.getAttribute("dataProcessingRef"); + if (!dataProcessingRef.equals("")) { // getAttribute returns empty String if no value was specified + setDataProcessingRef(dataProcessingRef); + } + String sourceFileRef = ele.getAttribute("sourceFileRef"); + if (!sourceFileRef.equals("")) { // getAttribute returns empty String if no value was specified + setSourceFileRef(sourceFileRef); + } + String msLevel = ele.getAttribute("msLevel"); + if (!msLevel.equals("")) { // getAttribute returns empty String if no value was specified + setMsLevel(Integer.parseInt(msLevel)); + } + String scanNumber = ele.getAttribute("scanNumber"); + if (!scanNumber.equals("")) { // getAttribute returns empty String if no value was specified + setScanNumber(Integer.parseInt(scanNumber)); + } + + // load elements + NodeList nl = ele.getElementsByTagName("spectrumDescription"); + // we only expect one such element! + if (nl.getLength() == 1) { + spectrumDescription = new SpectrumDescriptionType((Element) nl.item(0)); + } else { + throw new IllegalStateException("Expected only one 'spectrumDescription' element, but found: " + nl.getLength()); + } + nl = null; + nl = ele.getElementsByTagName("binaryDataArray"); + for ( int i = 0; i < nl.getLength(); i++ ) { + this.getBinaryDataArray().add(new BinaryDataArrayType((Element) nl.item(i))); + } + super.create(node); + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the spectrumDescription property. + * + * @return + * possible object is + * {@link SpectrumDescriptionType } + * + */ + public SpectrumDescriptionType getSpectrumDescription() { + return spectrumDescription; + } + + /** + * Sets the value of the spectrumDescription property. + * + * @param value + * allowed object is + * {@link SpectrumDescriptionType } + * + */ + public void setSpectrumDescription(SpectrumDescriptionType value) { + this.spectrumDescription = value; + } + + /** + * Gets the value of the binaryDataArray property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the binaryDataArray property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getBinaryDataArray().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link BinaryDataArrayType } + * + * + */ + public List getBinaryDataArray() { + if (binaryDataArray == null) { + binaryDataArray = new ArrayList(); + } + return this.binaryDataArray; + } + + /** + * Gets the value of the dataProcessingRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDataProcessingRef() { + return dataProcessingRef; + } + + /** + * Sets the value of the dataProcessingRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDataProcessingRef(String value) { + this.dataProcessingRef = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the msLevel property. + * + */ + public int getMsLevel() { + return msLevel; + } + + /** + * Sets the value of the msLevel property. + * + */ + public void setMsLevel(int value) { + this.msLevel = value; + } + + /** + * Gets the value of the scanNumber property. + * + */ + public int getScanNumber() { + return scanNumber; + } + + /** + * Sets the value of the scanNumber property. + * + */ + public void setScanNumber(int value) { + this.scanNumber = value; + } + + /** + * Gets the value of the sourceFileRef property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSourceFileRef() { + return sourceFileRef; + } + + /** + * Sets the value of the sourceFileRef property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSourceFileRef(String value) { + this.sourceFileRef = value; + } + + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/UserParamType.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/UserParamType.java new file mode 100644 index 0000000..dbdf26a --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/UserParamType.java @@ -0,0 +1,194 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + + +package psidev.psi.ms.mzml.mapping.jaxb; + +import org.w3c.dom.Element; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.w3c.dom.Node; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import java.io.ByteArrayInputStream; + + +/** + * Uncontrolled user parameters (vocabulary). + * + *

Java class for UserParamType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="UserParamType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "UserParamType") +public class UserParamType { + + @XmlAttribute(required = true) + protected String name; + @XmlAttribute(required = true) + protected String type; + @XmlAttribute(required = true) + protected String value; + + + private String elementName = "userParam"; + + public UserParamType() {} + + public UserParamType(String xmlSnippet) { + parseXml(xmlSnippet); + } + + public UserParamType(Element element) { + create(element); + } + + /////////////////// + // utilities + + private void parseXml(String xmlSnippet) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + ByteArrayInputStream str = new ByteArrayInputStream(xmlSnippet.getBytes()); + document = builder.parse( str ); + } catch ( Exception e ) { + e.printStackTrace(); + } + + + // we always expect a String representing a single xml tag, not a list of xml tags! + if (document != null) { + NodeList nl = document.getElementsByTagName(elementName); + if (nl.getLength() == 1) { + Element ele = (Element) nl.item(0); + create(ele); + } else { + throw new IllegalStateException("Expected only one '" + elementName + "' element, but found: " + nl.getLength()); + } + } + + } + + private void create(Node node) { + Element ele = (Element) node; + if (ele != null) { + // load attributes + String name = ele.getAttribute("name"); + if (!name.equals("")) { // getAttribute returns empty String if no value was specified + setName(name); + } + String type = ele.getAttribute("type"); + if (!type.equals("")) { // getAttribute returns empty String if no value was specified + setType(type); + } + String value = ele.getAttribute("value"); + if (!value.equals("")) { // getAttribute returns empty String if no value was specified + setValue(value); + } + // load elements + + } + } + + //////////////////// + // Getter + Setter + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/package-info.java b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/package-info.java new file mode 100644 index 0000000..27deab5 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/mzml/mapping/jaxb/package-info.java @@ -0,0 +1,9 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.1-b01-fcs +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2007.08.17 at 01:20:51 PM BST +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://psi.hupo.org/schema_revision/mzML_0.93", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package psidev.psi.ms.mzml.mapping.jaxb; diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/AcquisitionParametersFileRefObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/AcquisitionParametersFileRefObjectRule.java new file mode 100644 index 0000000..f9f8994 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/AcquisitionParametersFileRefObjectRule.java @@ -0,0 +1,90 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.ScanSettings; +import uk.ac.ebi.jmzml.model.mzml.SourceFileRef; + +/** + * Check if there is a reference to a source file in the scan settings + * parameters + * + * @author Salva + * + */ +public class AcquisitionParametersFileRefObjectRule extends ObjectRule { + + // Contexts + private static final Context sourceFileRefContext = new Context( + MzMLElement.SourceFileRef.getXpath()); + + private boolean acquisitionParameterFileRefError = false; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public AcquisitionParametersFileRefObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public AcquisitionParametersFileRefObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof ScanSettings); + } + + public Collection check(ScanSettings scanSettings) throws ValidatorException { + List messages = new ArrayList(); + + boolean acquisitionParameterFileRef = false; + + if (scanSettings.getSourceFileRefList() != null) { + for (SourceFileRef sourceFileRef : scanSettings.getSourceFileRefList() + .getSourceFileRef()) { + if (!acquisitionParameterFileRef) { + if (!"".equals(sourceFileRef.getRef())) + acquisitionParameterFileRef = true; + } + + } + if (!acquisitionParameterFileRef) { + messages.add(new ValidatorMessage( + "There is not a reference to an acquisition parameter file in " + + this.sourceFileRefContext.getContext(), MessageLevel.ERROR, + sourceFileRefContext, this)); + acquisitionParameterFileRefError = true; + } + + } + + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (acquisitionParameterFileRefError) + ret.add("Add reference to a source file in the attribute 'ref' in " + + this.sourceFileRefContext.getContext()); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/ExplicitAcquisitionParametersObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/ExplicitAcquisitionParametersObjectRule.java new file mode 100644 index 0000000..efd0a24 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/ExplicitAcquisitionParametersObjectRule.java @@ -0,0 +1,114 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.ontology_manager.OntologyUtils; +import psidev.psi.tools.ontology_manager.impl.OntologyTermImpl; +import psidev.psi.tools.ontology_manager.interfaces.OntologyAccess; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.Software; +import uk.ac.ebi.jmzml.model.mzml.SoftwareList; + +/** + * Check if the acquisition software has an explicit description of the + * parameters + * + * @author Salva + * + */ +public class ExplicitAcquisitionParametersObjectRule extends ObjectRule { + + private static final String ACQUISITON_SOFTWARE_ACC = "MS:1001455"; + // TODO change the DATA_PROCESSING_PARAMETER_ACC by the new term for + // "acquisition parameters" + private static final String DATA_PROCESSING_PARAMETER_ACC = "MS:1000630"; + + // Contexts + private static final Context softwareContext = new Context(MzMLElement.Software.getXpath()); + + private boolean acquisitionSoftwareError = false; + private Collection acquisitionSoftwareTerms; + private Collection acquisitionParametersTerms; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public ExplicitAcquisitionParametersObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public ExplicitAcquisitionParametersObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + // Get necessary terms from ontology + getRequiredAccessionsFromOntology(); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SoftwareList); + } + + public Collection check(SoftwareList softwareList) throws ValidatorException { + List messages = new ArrayList(); + + boolean acquisitionSoftwareWithParameters = false; + + if (softwareList.getSoftware() != null) { + for (Software software : softwareList.getSoftware()) { + if (!acquisitionSoftwareWithParameters) { + if (!ObjectRuleUtil.checkAccessionsInCVParams(software.getCvParam(), + acquisitionSoftwareTerms).isEmpty()) + if (!ObjectRuleUtil.checkAccessionsInCVParams(software.getCvParam(), + acquisitionParametersTerms).isEmpty()) + acquisitionSoftwareWithParameters = true; + } + + } + if (!acquisitionSoftwareWithParameters) { + messages.add(new ValidatorMessage( + "No explicit description of acquisition parameters have been provided in the acquisition software", + MessageLevel.ERROR, softwareContext, this)); + acquisitionSoftwareError = true; + } + + } + + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (acquisitionSoftwareError) + ret.add("Add a children of 'data processing parameter' (" + + DATA_PROCESSING_PARAMETER_ACC + ") in the acquisition software provided in " + + this.softwareContext.getContext()); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + + private void getRequiredAccessionsFromOntology() { + final OntologyAccess msOntology = ontologyManager.getOntologyAccess("MS"); + + this.acquisitionSoftwareTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(ACQUISITON_SOFTWARE_ACC))); + + this.acquisitionParametersTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(DATA_PROCESSING_PARAMETER_ACC))); + this.acquisitionParametersTerms.add(DATA_PROCESSING_PARAMETER_ACC); + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/InstrumentConfigurationObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/InstrumentConfigurationObjectRule.java new file mode 100644 index 0000000..d2997bb --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/InstrumentConfigurationObjectRule.java @@ -0,0 +1,156 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.ontology_manager.OntologyUtils; +import psidev.psi.tools.ontology_manager.impl.OntologyTermImpl; +import psidev.psi.tools.ontology_manager.interfaces.OntologyAccess; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.CVParam; +import uk.ac.ebi.jmzml.model.mzml.InstrumentConfiguration; + +/** + * Checks if the manufacturer and model are in the cv terms of the instrument + * configuration as well as the customization term value is not empty + * + * @author Salva + * + */ +public class InstrumentConfigurationObjectRule extends ObjectRule { + + private static final String INSTRUMENT_MODEL_ACC = "MS:1000031"; + private static final String CUSTOMIZATION_ACC = "MS:1000032"; + private Collection manufacturerAccessions; + private ArrayList instrumentModelAccessions; + private int error = -1; + private Context instrumentConfigurationCvParamContext = new Context( + MzMLElement.InstrumentConfiguration.getXpath() + "/cvParam"); + private final int MANUFACTURER_ERROR = 2; + private final int MODEL_ERROR = 1; + private final int CUSTOMIZATION_ERROR = 3; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public InstrumentConfigurationObjectRule() { + this(null); + + } + + // Anothe constructor that calls to ObjectRule + public InstrumentConfigurationObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + // Get necessary terms from ontology + getRequiredAccessionsFromOntology(); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof InstrumentConfiguration); + } + + public Collection check(InstrumentConfiguration instrumentConfiguration) + throws ValidatorException { + List messages = new ArrayList(); + + // Check instrument manufacturer + messages.addAll(checkManufacturer(instrumentConfiguration)); + + // Check instrument model + messages.addAll(checkInstrumentModel(instrumentConfiguration)); + + // Check customizations + messages.addAll(checkCustomizations(instrumentConfiguration)); + + // return messages + return messages; + } + + private Collection checkCustomizations( + InstrumentConfiguration instrumentConfiguration) { + List messages = new ArrayList(); + final List cvParams = instrumentConfiguration.getCvParam(); + final CVParam customizations = ObjectRuleUtil.checkAccessionsInCVParams(cvParams, + this.CUSTOMIZATION_ACC); + if (customizations != null) { + if (customizations.getValue() == null || "".equals(customizations.getValue())) + messages.add(new ValidatorMessage("No value in 'customizations' term (" + + this.CUSTOMIZATION_ACC + ") for the instrumentConfiguration id=" + + instrumentConfiguration.getId(), MessageLevel.ERROR, + instrumentConfigurationCvParamContext, this)); + error = CUSTOMIZATION_ERROR; + } + return messages; + } + + private Collection checkInstrumentModel( + InstrumentConfiguration instrumentConfiguration) { + List messages = new ArrayList(); + final List cvParams = instrumentConfiguration.getCvParam(); + if (ObjectRuleUtil.checkAccessionsInCVParams(cvParams, instrumentModelAccessions).isEmpty()) { + messages.add(new ValidatorMessage("No instrument model in instrumentConfiguration id=" + + instrumentConfiguration.getId(), MessageLevel.ERROR, + instrumentConfigurationCvParamContext, this)); + error = MODEL_ERROR; + } + return messages; + } + + private Collection checkManufacturer( + InstrumentConfiguration instrumentConfiguration) { + List messages = new ArrayList(); + final List cvParams = instrumentConfiguration.getCvParam(); + if (ObjectRuleUtil.checkAccessionsInCVParams(cvParams, manufacturerAccessions).isEmpty()) { + messages.add(new ValidatorMessage( + "No instrument manufacturer in instrumentConfiguration id=" + + instrumentConfiguration.getId(), MessageLevel.ERROR, + instrumentConfigurationCvParamContext, this)); + error = MANUFACTURER_ERROR; + } + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (error == MODEL_ERROR) { + ret.add("Add a grandson of 'instrument model' (" + INSTRUMENT_MODEL_ACC + ") in " + + instrumentConfigurationCvParamContext.getContext()); + } else if (error == MANUFACTURER_ERROR) { + ret.add("Add a direct children of 'instrument model' (" + INSTRUMENT_MODEL_ACC + + ") in " + instrumentConfigurationCvParamContext.getContext()); + } else if (error == CUSTOMIZATION_ERROR) { + ret.add("Add a non empty value in the term 'customizations' (" + CUSTOMIZATION_ACC + + ") in " + instrumentConfigurationCvParamContext.getContext()); + } + return ret; + } + + private void getRequiredAccessionsFromOntology() { + final OntologyAccess msOntology = ontologyManager.getOntologyAccess("MS"); + this.manufacturerAccessions = OntologyUtils.getAccessions(msOntology + .getDirectChildren(new OntologyTermImpl(INSTRUMENT_MODEL_ACC))); + if (manufacturerAccessions != null) { + this.instrumentModelAccessions = new ArrayList(); + for (String manufacturerAccession : manufacturerAccessions) { + instrumentModelAccessions.addAll(OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(manufacturerAccession)))); + } + } + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/LaserWavelengthObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/LaserWavelengthObjectRule.java new file mode 100644 index 0000000..ae1d820 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/LaserWavelengthObjectRule.java @@ -0,0 +1,76 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.CVParam; +import uk.ac.ebi.jmzml.model.mzml.SourceComponent; + +/** + * Check if the wavelength CV Term has an empty value + * + * @author Salva + * + */ +public class LaserWavelengthObjectRule extends ObjectRule { + + private static final String LASER_WAVELENGTH_ACC = "MS:1000843"; + private Context sourceComponentCvParamContext = new Context( + MzMLElement.SourceComponent.getXpath() + "/cvParam"); + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public LaserWavelengthObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public LaserWavelengthObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SourceComponent); + } + + public Collection check(SourceComponent sourceComponent) + throws ValidatorException { + Collection messages = new ArrayList(); + + final CVParam laserWavelengthCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + sourceComponent.getCvParam(), this.LASER_WAVELENGTH_ACC); + if (laserWavelengthCVParam != null) + if (laserWavelengthCVParam.getValue() == null + || "".equals(laserWavelengthCVParam.getValue())) + messages.add(new ValidatorMessage("Laser wavelenth value is empty", + MessageLevel.ERROR, this.sourceComponentCvParamContext, this)); + // return messages"ObjectRules.xml" + return messages; + } + + @Override + public Collection getHowToFixTips() { + Collection ret = new ArrayList(); + + ret.add("Add a non empty value in the cvParam 'wavelength' (" + LASER_WAVELENGTH_ACC + + ") in " + this.sourceComponentCvParamContext.getContext()); + + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/MandatoryElementsObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/MandatoryElementsObjectRule.java new file mode 100644 index 0000000..ffda22f --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/MandatoryElementsObjectRule.java @@ -0,0 +1,42 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; + +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; + +/** + * This class is for displaying a validator FATAL message when an exception is + * thrown by the psi xml parser.
+ * This rule is not in the list of object rules to execute. + * + */ + +public class MandatoryElementsObjectRule extends ObjectRule { + public MandatoryElementsObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + + setName("Mandatory element check"); + + setDescription("Check that some elements in the xml file are present or not."); + + addTip("Add the element in the appropiate location."); + } + + @Override + public boolean canCheck(Object t) { + return true; + } + + @Override + public Collection check(Object o) throws ValidatorException { + return new ArrayList(); + } + + public String getId() { + return this.getClass().getSimpleName(); + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/MassSpectraOrParameterFileInSourceFileListObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/MassSpectraOrParameterFileInSourceFileListObjectRule.java new file mode 100644 index 0000000..5df60a3 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/MassSpectraOrParameterFileInSourceFileListObjectRule.java @@ -0,0 +1,153 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.ontology_manager.OntologyUtils; +import psidev.psi.tools.ontology_manager.impl.OntologyTermImpl; +import psidev.psi.tools.ontology_manager.interfaces.OntologyAccess; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.SourceFile; +import uk.ac.ebi.jmzml.model.mzml.SourceFileList; + +/** + * Check if there is an spectra file or a parameter file in the source file list + * + * @author Salva + * + */ +public class MassSpectraOrParameterFileInSourceFileListObjectRule extends + ObjectRule { + + // Contexts + private static final Context sourceFileContext = new Context(MzMLElement.SourceFile.getXpath()); + private static final String PARAMETER_FILE_ACC = "MS:1000740"; + private static final String MASS_SPECTROMETER_FILE_FORMAT_ACC = "MS:1000560"; + private static final String DATA_FILE_CHECKSUM_TYPE_ACC = "MS:1000561"; + private static final String NATIVE_SPECTRUM_IDENTIFIER_FORMAT = "MS:1000767"; + private Collection dataFileChecksumTypeTerms; + private Collection massSpectrometryFileFormatTerms; + private Collection nativeSpectrumIdentifierFormatTerms; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public MassSpectraOrParameterFileInSourceFileListObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public MassSpectraOrParameterFileInSourceFileListObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + getRequiredAccessionsFromOntology(); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SourceFileList); + } + + public Collection check(SourceFileList sourceFileList) + throws ValidatorException { + List messages = new ArrayList(); + + if (sourceFileList.getSourceFile() != null) { + + for (SourceFile sourceFile : sourceFileList.getSourceFile()) { + boolean parameterFileError = false; + boolean massSpectrometerFileTypeFormatError = false; + boolean nativeSpectrumIdentifierFormatError = false; + boolean dataFileChecksumTypeError = false; + // PARAMETER FILE + if (ObjectRuleUtil.checkAccessionsInCVParams(sourceFile.getCvParam(), + this.PARAMETER_FILE_ACC) == null) + parameterFileError = true; + // MASS SPECTRA FILE FORMAT + if (ObjectRuleUtil.checkAccessionsInCVParams(sourceFile.getCvParam(), + this.massSpectrometryFileFormatTerms).isEmpty()) + massSpectrometerFileTypeFormatError = true; + // DATA FILE CHECKSUM TYPE + if (ObjectRuleUtil.checkAccessionsInCVParams(sourceFile.getCvParam(), + this.dataFileChecksumTypeTerms).isEmpty()) + dataFileChecksumTypeError = true; + // NATIVE SPECTRUM IDENTIFIER FORMAT + if (ObjectRuleUtil.checkAccessionsInCVParams(sourceFile.getCvParam(), + this.nativeSpectrumIdentifierFormatTerms).isEmpty()) + nativeSpectrumIdentifierFormatError = true; + + // CREATE MESSAGE ERRORS + if (parameterFileError + && (massSpectrometerFileTypeFormatError || dataFileChecksumTypeError || nativeSpectrumIdentifierFormatError)) { + // No Paramter file neither any of the mass spectrometer + // file CV terms + if (massSpectrometerFileTypeFormatError && dataFileChecksumTypeError + && nativeSpectrumIdentifierFormatError) { + messages.add(new ValidatorMessage("The source file '" + sourceFile.getId() + + "' is neither a mass spectrometer file nor a parameter file", + MessageLevel.ERROR, sourceFileContext, this)); + } else { + messages.add(getMessage(sourceFile.getId(), + massSpectrometerFileTypeFormatError, dataFileChecksumTypeError, + nativeSpectrumIdentifierFormatError)); + } + } + } + } + + return messages; + } + + private ValidatorMessage getMessage(String sourceFileId, + boolean massSpectrometerFileTypeFormatError, boolean dataFileChecksumTypeError, + boolean nativeSpectrumIdentifierFormatError) { + StringBuilder sb = new StringBuilder(); + if (massSpectrometerFileTypeFormatError) + sb.append("The term 'mass spectrometer file format' (" + + this.MASS_SPECTROMETER_FILE_FORMAT_ACC + ") is not present"); + if (dataFileChecksumTypeError) { + if (!"".equals(sb.toString())) + sb.append("\n"); + sb.append("The term 'data file checksum type' (" + this.DATA_FILE_CHECKSUM_TYPE_ACC + + ") is not present"); + } + if (nativeSpectrumIdentifierFormatError) { + if (!"".equals(sb.toString())) + sb.append("\n"); + sb.append("The term 'native spectrum identifier format' (" + + this.NATIVE_SPECTRUM_IDENTIFIER_FORMAT + ") is not present"); + } + sb.append("\n in source file id='" + sourceFileId + "'"); + return new ValidatorMessage(sb.toString(), MessageLevel.ERROR, this.sourceFileContext, this); + } + + @Override + public Collection getHowToFixTips() { + return new ArrayList(); + } + + public String getId() { + return this.getClass().getSimpleName(); + } + + private void getRequiredAccessionsFromOntology() { + final OntologyAccess msOntology = ontologyManager.getOntologyAccess("MS"); + + this.dataFileChecksumTypeTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(this.DATA_FILE_CHECKSUM_TYPE_ACC))); + + this.massSpectrometryFileFormatTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(this.MASS_SPECTROMETER_FILE_FORMAT_ACC))); + + this.nativeSpectrumIdentifierFormatTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(this.NATIVE_SPECTRUM_IDENTIFIER_FORMAT))); + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/MatrixSolutionObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/MatrixSolutionObjectRule.java new file mode 100644 index 0000000..6697dd2 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/MatrixSolutionObjectRule.java @@ -0,0 +1,77 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.CVParam; +import uk.ac.ebi.jmzml.model.mzml.SourceComponent; + +/** + * Check if there is a matrix solution cv term in the source component, and if + * the value is empty or not. + * + * @author Salva + * + */ +public class MatrixSolutionObjectRule extends ObjectRule { + + private static final String MATRIX_SOLUTION_ACC = "MS:1000834"; + private Context sourceComponentCvParamContext = new Context( + MzMLElement.SourceComponent.getXpath() + "/cvParam"); + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public MatrixSolutionObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public MatrixSolutionObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SourceComponent); + } + + public Collection check(SourceComponent sourceComponent) + throws ValidatorException { + Collection messages = new ArrayList(); + + final CVParam matrixSolutionCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + sourceComponent.getCvParam(), this.MATRIX_SOLUTION_ACC); + if (matrixSolutionCVParam != null) + if (matrixSolutionCVParam.getValue() == null + || "".equals(matrixSolutionCVParam.getValue())) + messages.add(new ValidatorMessage("Matrix solution value is empty", + MessageLevel.ERROR, this.sourceComponentCvParamContext, this)); + // return messages"ObjectRules.xml" + return messages; + } + + @Override + public Collection getHowToFixTips() { + Collection ret = new ArrayList(); + + ret.add("Add a non empty value in the cvParam 'matrix solution' (" + MATRIX_SOLUTION_ACC + + ") in " + this.sourceComponentCvParamContext.getContext()); + + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/OtherSourceObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/OtherSourceObjectRule.java new file mode 100644 index 0000000..e8e5761 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/OtherSourceObjectRule.java @@ -0,0 +1,109 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.ontology_manager.OntologyUtils; +import psidev.psi.tools.ontology_manager.impl.OntologyTermImpl; +import psidev.psi.tools.ontology_manager.interfaces.OntologyAccess; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.CVParam; +import uk.ac.ebi.jmzml.model.mzml.SourceComponent; + +/** + * Check if the source component is any other ionization source different from + * MALDI or ESI + * + * @author Salva + * + */ +public class OtherSourceObjectRule extends ObjectRule { + + private static final String ESI_ACC = "MS:1000073"; + private static final String MALDI_ACC = "MS:1000075"; + private Context sourceComponentCvParamContext = new Context( + MzMLElement.SourceComponent.getXpath() + "/cvParam"); + private Collection esiRelatedTerms; + final OntologyAccess msOntology = ontologyManager.getOntologyAccess("MS"); + private int error = -1; + private int ESI_ERROR = 1; + private int MALDI_ERROR = 2; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public OtherSourceObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public OtherSourceObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SourceComponent); + } + + public Collection check(SourceComponent sourceComponent) + throws ValidatorException { + Collection messages = new ArrayList(); + + // Check if some ESI related term is in source + final List esiCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + sourceComponent.getCvParam(), this.esiRelatedTerms); + if (esiCVParam != null && !esiCVParam.isEmpty()) { + messages.add(new ValidatorMessage(esiCVParam.iterator().next().getName() + " (" + + esiCVParam.iterator().next().getAccession() + + ") term found in source element. Select ESI source instead of OTHER source", + MessageLevel.ERROR, this.sourceComponentCvParamContext, this)); + this.error = ESI_ERROR; + } + // Check if MALDI term is in source + final CVParam maldiCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + sourceComponent.getCvParam(), this.MALDI_ACC); + if (maldiCVParam != null) { + messages.add(new ValidatorMessage( + maldiCVParam.getName() + + " (" + + maldiCVParam.getAccession() + + ") term found in source element. Select MALDI source instead of OTHER source", + MessageLevel.ERROR, this.sourceComponentCvParamContext, this)); + this.error = MALDI_ERROR; + } + + // return messages"ObjectRules.xml" + return messages; + } + + @Override + public Collection getHowToFixTips() { + Collection ret = new ArrayList(); + if (this.error == this.ESI_ERROR) + ret.add("Select ESI source and start the validation again"); + else if (this.error == this.MALDI_ERROR) + ret.add("Select MALDI source and start the validation again"); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + + private void getRequiredAccessionsFromOntology() { + + this.esiRelatedTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(this.ESI_ACC))); + this.esiRelatedTerms.add(ESI_ACC); + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/ParameterFileInSourceFileListObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/ParameterFileInSourceFileListObjectRule.java new file mode 100644 index 0000000..7827ece --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/ParameterFileInSourceFileListObjectRule.java @@ -0,0 +1,93 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.ScanSettings; +import uk.ac.ebi.jmzml.model.mzml.SourceFile; +import uk.ac.ebi.jmzml.model.mzml.SourceFileList; + +/** + * Check if one source file in the source file list is a parameter file or not + * + * @author Salva + * + */ +public class ParameterFileInSourceFileListObjectRule extends ObjectRule { + + // Contexts + private static final Context sourceFileListContext = new Context( + MzMLElement.SourceFileList.getXpath()); + + private static final String PARAMETER_FILE_ACC = "MS:1000740"; + + private boolean acquisitionParameterFileError = false; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public ParameterFileInSourceFileListObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public ParameterFileInSourceFileListObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof ScanSettings); + } + + public Collection check(SourceFileList sourceFileList) + throws ValidatorException { + List messages = new ArrayList(); + + boolean acquisitionParameterFile = false; + + if (sourceFileList.getSourceFile() != null) { + for (SourceFile sourceFile : sourceFileList.getSourceFile()) { + if (!acquisitionParameterFile) { + if (ObjectRuleUtil.checkAccessionsInCVParams(sourceFile.getCvParam(), + this.PARAMETER_FILE_ACC) != null) + acquisitionParameterFile = true; + } + } + if (!acquisitionParameterFile) { + messages.add(new ValidatorMessage( + "There is not a parameter file in the source file list in " + + this.sourceFileListContext.getContext(), MessageLevel.ERROR, + sourceFileListContext, this)); + acquisitionParameterFileError = true; + } + + } + + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (acquisitionParameterFileError) + ret.add("Add sourceFile as a acquisition 'parameter file' (" + this.PARAMETER_FILE_ACC + + ") in " + this.sourceFileListContext.getContext()); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/SoftwareListObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/SoftwareListObjectRule.java new file mode 100644 index 0000000..17ec0fa --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/SoftwareListObjectRule.java @@ -0,0 +1,119 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.ontology_manager.OntologyUtils; +import psidev.psi.tools.ontology_manager.impl.OntologyTermImpl; +import psidev.psi.tools.ontology_manager.interfaces.OntologyAccess; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.Software; +import uk.ac.ebi.jmzml.model.mzml.SoftwareList; + +/** + * Check if there is an acquisition software and a data processing software in + * the software list + * + * @author Salva + * + */ +public class SoftwareListObjectRule extends ObjectRule { + + private static final String ACQUISITON_SOFTWARE_ACC = "MS:1001455"; + private static final String DATA_PROCESSING_SOFTWARE_ACC = "MS:1001457"; + + // Contexts + private static final Context softwareContext = new Context(MzMLElement.Software.getXpath()); + + private boolean acquisitionSoftwareError = false; + private boolean dataProcessingSoftwareError = false; + private Collection acquisitionSoftwareTerms; + private Collection dataProcessingSoftwareTerms; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public SoftwareListObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public SoftwareListObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + // Get necessary terms from ontology + getRequiredAccessionsFromOntology(); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof SoftwareList); + } + + public Collection check(SoftwareList softwareList) throws ValidatorException { + List messages = new ArrayList(); + boolean dataAnalysisSoftware = false; + boolean acquisitionSoftware = false; + + if (softwareList.getSoftware() != null) { + for (Software software : softwareList.getSoftware()) { + if (!acquisitionSoftware) + if (!ObjectRuleUtil.checkAccessionsInCVParams(software.getCvParam(), + acquisitionSoftwareTerms).isEmpty()) + acquisitionSoftware = true; + if (!dataAnalysisSoftware) + if (!ObjectRuleUtil.checkAccessionsInCVParams(software.getCvParam(), + dataProcessingSoftwareTerms).isEmpty()) + dataAnalysisSoftware = true; + } + if (!acquisitionSoftware) { + messages.add(new ValidatorMessage( + "No acquisition software provided in the software list", + MessageLevel.ERROR, softwareContext, this)); + acquisitionSoftwareError = true; + } + if (!dataAnalysisSoftware) { + messages.add(new ValidatorMessage( + "No data processing software provided in the software list", + MessageLevel.ERROR, softwareContext, this)); + dataProcessingSoftwareError = true; + } + } + + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (dataProcessingSoftwareError) + ret.add("Add a children of 'data processing software' (" + DATA_PROCESSING_SOFTWARE_ACC + + ") in " + this.softwareContext.getContext()); + if (acquisitionSoftwareError) + ret.add("Add a children of 'acquisition software' (" + ACQUISITON_SOFTWARE_ACC + + ") in " + this.softwareContext.getContext()); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + + private void getRequiredAccessionsFromOntology() { + final OntologyAccess msOntology = ontologyManager.getOntologyAccess("MS"); + this.acquisitionSoftwareTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(ACQUISITON_SOFTWARE_ACC))); + + this.dataProcessingSoftwareTerms = OntologyUtils.getAccessions(msOntology + .getAllChildren(new OntologyTermImpl(DATA_PROCESSING_SOFTWARE_ACC))); + + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/SpectrumObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/SpectrumObjectRule.java new file mode 100644 index 0000000..a3df699 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/SpectrumObjectRule.java @@ -0,0 +1,252 @@ +package psidev.psi.ms.object_rules; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import psidev.psi.ms.object_rules.util.ObjectRuleUtil; +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.Context; +import psidev.psi.tools.validator.MessageLevel; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import uk.ac.ebi.jmzml.MzMLElement; +import uk.ac.ebi.jmzml.model.mzml.BinaryDataArray; +import uk.ac.ebi.jmzml.model.mzml.CVParam; +import uk.ac.ebi.jmzml.model.mzml.ParamGroup; +import uk.ac.ebi.jmzml.model.mzml.Precursor; +import uk.ac.ebi.jmzml.model.mzml.Spectrum; + +/** + * Check if the collision gas CV Term in activation has an empty value. Check if + * binary data array is empty. + * + * @author Salva + * + */ +public class SpectrumObjectRule extends ObjectRule { + + private static final String COLLISION_GAS_ACC = "MS:1000419"; + private static final String MS_LEVEL_ACC = "MS:1000511"; + private static final String CHARGE_STATE_ACC = "MS:1000041"; + private static final String POSSIBLE_CHARGE_STATE_ACC = "MS:1000633"; + + // Contexts + private static final Context precursorActivationContext = new Context( + MzMLElement.Precursor.getXpath() + "/activation/cvParam"); + private static final Context binaryDataArrayContext = new Context( + MzMLElement.Spectrum.getXpath() + "/binaryDataArrayList/binary"); + private static final Context spectrumContext = new Context(MzMLElement.Spectrum.getXpath() + + "/cvParam"); + private static final Context selectedIonContext = new Context( + MzMLElement.SelectedIonList.getXpath() + "/selectedIon/cvParam"); + private static final Context precursorContext = new Context(MzMLElement.Precursor.getXpath()); + + private boolean collisionGasEmpty = false; + private boolean binaryDataArrayEmpty = false; + private boolean msLevelEmpty = false; + private boolean possibleChargeStateEmpty = false; + private boolean chargeStateEmpty = false; + private boolean precursorEmpty = false; + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public SpectrumObjectRule() { + this(null); + } + + // Anothe constructor that calls to ObjectRule + public SpectrumObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return (o instanceof Spectrum); + } + + public Collection check(Spectrum spectrum) throws ValidatorException { + List messages = new ArrayList(); + + if (spectrum.getPrecursorList() != null) { + for (Precursor precursor : spectrum.getPrecursorList().getPrecursor()) { + if (precursor.getActivation() != null) { + // COLLISION GAS EMPTY + messages.addAll(checkActivation(precursor.getActivation())); + } + // CHARGE STATE or POSSIBLE CHARGE STATE EMPTY + if (precursor.getSelectedIonList() != null) { + for (ParamGroup selectedIon : precursor.getSelectedIonList().getSelectedIon()) { + messages.addAll(checkSelectedIon(selectedIon)); + } + } + } + } + // BINARY DATA ARRAY EMPTY + messages.addAll(checkBinaryDataArray(spectrum)); + + // MS LEVEL EMPTY + messages.addAll(checkMSLevel(spectrum)); + + // IF MS LEVEL > 2, then check if a precursor is provided + int msLevel = getMSLevel(spectrum); + if (msLevel >= 2) { + messages.addAll(checkPrecursor(spectrum)); + } + return messages; + } + + private List checkPrecursor(Spectrum spectrum) { + List messages = new ArrayList(); + boolean spectrumRef = true; + boolean externalSpectrum = true; + this.precursorEmpty = false; + if (spectrum.getPrecursorList() != null) { + for (Precursor precursor : spectrum.getPrecursorList().getPrecursor()) { + if (precursor.getSpectrumRef() == null || "".equals(precursor.getSpectrumRef())) + spectrumRef = false; + if (precursor.getSourceFileRef() == null || "".equals(precursor.getSourceFileRef()) + || precursor.getExternalSpectrumID() == null + || "".equals(precursor.getExternalSpectrumID())) + externalSpectrum = false; + if (!spectrumRef && !externalSpectrum) { + messages.add(getPrecursorEmptyError(spectrum)); + this.precursorEmpty = true; + } + } + } else { + messages.add(getPrecursorEmptyError(spectrum)); + } + + return messages; + } + + private ValidatorMessage getPrecursorEmptyError(Spectrum spectrum) { + return new ValidatorMessage( + "There is not a spectrum reference for spectrum (required for MS level >= 2 spectra)", + MessageLevel.ERROR, this.precursorContext, this); + } + + private List checkMSLevel(Spectrum spectrum) { + List messages = new ArrayList(); + this.msLevelEmpty = false; + if (spectrum.getCvParam() != null) { + final CVParam msLevelCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + spectrum.getCvParam(), this.MS_LEVEL_ACC); + if (msLevelCVParam != null) { + if (msLevelCVParam.getValue() == null || "".equals(msLevelCVParam.getValue())) { + messages.add(new ValidatorMessage("MS level value is empty", + MessageLevel.ERROR, this.spectrumContext, this)); + this.msLevelEmpty = true; + } + } + } + return messages; + } + + private int getMSLevel(Spectrum spectrum) { + if (spectrum.getCvParam() != null) { + final CVParam msLevelCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + spectrum.getCvParam(), this.MS_LEVEL_ACC); + if (msLevelCVParam != null) { + if (msLevelCVParam.getValue() != null && !"".equals(msLevelCVParam.getValue())) { + try { + return Integer.valueOf(msLevelCVParam.getValue()); + } catch (Exception e) { + // do nothing + } + } + } + } + return -1; + } + + private List checkBinaryDataArray(Spectrum spectrum) { + List messages = new ArrayList(); + this.binaryDataArrayEmpty = false; + if (spectrum.getBinaryDataArrayList() != null) + for (BinaryDataArray binaryDataArray : spectrum.getBinaryDataArrayList() + .getBinaryDataArray()) { + if (binaryDataArray.getBinary().length == 0) { + messages.add(new ValidatorMessage("Binary data array is empty", + MessageLevel.ERROR, this.binaryDataArrayContext, this)); + this.binaryDataArrayEmpty = true; + } + } + return messages; + } + + private List checkActivation(ParamGroup activation) { + List messages = new ArrayList(); + this.collisionGasEmpty = false; + final CVParam collisionGasCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + activation.getCvParam(), this.COLLISION_GAS_ACC); + if (collisionGasCVParam != null) { + if (collisionGasCVParam.getValue() == null || "".equals(collisionGasCVParam.getValue())) { + messages.add(new ValidatorMessage("Collision gas value is empty", + MessageLevel.ERROR, this.precursorActivationContext, this)); + this.collisionGasEmpty = true; + } + } + return messages; + } + + private List checkSelectedIon(ParamGroup selectedIon) { + List messages = new ArrayList(); + this.chargeStateEmpty = false; + this.possibleChargeStateEmpty = false; + final CVParam chargeStateCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + selectedIon.getCvParam(), this.CHARGE_STATE_ACC); + if (chargeStateCVParam != null) { + if (chargeStateCVParam.getValue() == null || "".equals(chargeStateCVParam.getValue())) { + messages.add(new ValidatorMessage("Charge state value is empty", + MessageLevel.ERROR, this.selectedIonContext, this)); + this.chargeStateEmpty = true; + } + } + final CVParam possibleChargeStateCVParam = ObjectRuleUtil.checkAccessionsInCVParams( + selectedIon.getCvParam(), this.POSSIBLE_CHARGE_STATE_ACC); + if (possibleChargeStateCVParam != null) { + if (possibleChargeStateCVParam.getValue() == null + || "".equals(possibleChargeStateCVParam.getValue())) { + messages.add(new ValidatorMessage("Possible charge state value is empty", + MessageLevel.ERROR, this.selectedIonContext, this)); + this.possibleChargeStateEmpty = true; + } + } + return messages; + } + + @Override + public Collection getHowToFixTips() { + List ret = new ArrayList(); + if (collisionGasEmpty) + ret.add("Add a non empty value in the cvParam 'collision gas' (" + COLLISION_GAS_ACC + + ") in " + this.precursorActivationContext.getContext()); + if (binaryDataArrayEmpty) + ret.add("Add a non empty value in the binaryDataArray in " + + this.binaryDataArrayContext.getContext()); + if (msLevelEmpty) + ret.add("Add a non empty value in the cvParam 'ms level' (" + MS_LEVEL_ACC + ") in " + + this.spectrumContext.getContext()); + if (chargeStateEmpty) + ret.add("Add a non empty value in the cvParam 'charge state' (" + CHARGE_STATE_ACC + + ") in " + this.selectedIonContext.getContext()); + if (possibleChargeStateEmpty) + ret.add("Add a non empty value in the cvParam 'possible charge state' (" + + POSSIBLE_CHARGE_STATE_ACC + ") in " + this.selectedIonContext.getContext()); + if (precursorEmpty) + ret.add("Add the attribute 'spectrumRef' to refer to the precursor spectra in the document." + + " It can also be provided by the attribute 'externalSpectrumID' together with 'sourceFileRef' that refer to an external spectrum ID. " + + precursorContext.getContext()); + return ret; + } + + public String getId() { + return this.getClass().getSimpleName(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/TemplateObjectRule.java b/validator/src/main/java/psidev/psi/ms/object_rules/TemplateObjectRule.java new file mode 100644 index 0000000..4ae984e --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/TemplateObjectRule.java @@ -0,0 +1,45 @@ +package psidev.psi.ms.object_rules; + +import java.util.Collection; + +import psidev.psi.tools.ontology_manager.OntologyManager; +import psidev.psi.tools.validator.ValidatorException; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; + +/** + * Created by IntelliJ IDEA. User: javizca Date: 16-jul-2008 Time: 9:37:28 To + * change this template use File | Settings | File Templates. + */ +public class TemplateObjectRule extends ObjectRule { + + // We had a problem with the default constructor. It was necessary to build + // a new one this way to call the ObjectRule + // constructor (below): + public TemplateObjectRule() { + this(null); + + } + + // Anothe constructor that calls to ObjectRule + public TemplateObjectRule(OntologyManager ontologyManager) { + super(ontologyManager); + } + + // We have to implement the abstract methods of the abstract class + // ObjectRule. + public boolean canCheck(Object o) { + return false; // To change body of implemented methods use File | + // Settings | File Templates. + } + + public Collection check(Object o) throws ValidatorException { + return null; // To change body of implemented methods use File | + // Settings | File Templates. + } + + public String getId() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/object_rules/util/ObjectRuleUtil.java b/validator/src/main/java/psidev/psi/ms/object_rules/util/ObjectRuleUtil.java new file mode 100644 index 0000000..c873fca --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/object_rules/util/ObjectRuleUtil.java @@ -0,0 +1,45 @@ +package psidev.psi.ms.object_rules.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import uk.ac.ebi.jmzml.model.mzml.CVParam; + +public class ObjectRuleUtil { + /** + * Check if any of the cvParams is one of the accessions + * + * @param cvParams + * @param accessions + * @return The list of {@link CVParam} found, or an empty list if not found + **/ + public static List checkAccessionsInCVParams(List cvParams, + Collection accessions) { + List ret = new ArrayList(); + if (cvParams != null && accessions != null) + + for (String accession : accessions) { + CVParam cvParam = checkAccessionsInCVParams(cvParams, accession); + if (cvParam != null) + ret.add(cvParam); + } + return ret; + } + + /** + * Check if any of the cvParams is the accession + * + * @param cvParams + * @param accession + * @return The CVParam found or null if not found + */ + public static CVParam checkAccessionsInCVParams(List cvParams, String accession) { + if (cvParams != null && accession != null) + for (CVParam cvParam : cvParams) { + if (accession.equals(cvParam.getAccession())) + return cvParam; + } + return null; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/MaldiOrEsiCondition.java b/validator/src/main/java/psidev/psi/ms/rulefilter/MaldiOrEsiCondition.java new file mode 100644 index 0000000..693e3ad --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/MaldiOrEsiCondition.java @@ -0,0 +1,18 @@ +package psidev.psi.ms.rulefilter; + +public enum MaldiOrEsiCondition { + MALDI("MALDI"), ESI("ESI"), OTHER("OTHER"); + private final String option; + + public static String getID() { + return "MALDI_OR_ESI"; + } + + MaldiOrEsiCondition(String option) { + this.option = option; + } + + public String getOption() { + return this.option; + } +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterAgent.java b/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterAgent.java new file mode 100644 index 0000000..dd683b9 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterAgent.java @@ -0,0 +1,27 @@ +package psidev.psi.ms.rulefilter; + +import java.util.HashMap; + +import psidev.psi.ms.rulefilter.jaxb.UserCondition; +import psidev.psi.ms.rulefilter.jaxb.UserOption; + +/** + * Interface that provides the methods to implement that parse rule filter xml + * files. That files follow the xsd schema located at: + * http://proteo.cnb.csic.es/miape-api/schemas/ruleFilter_v1.2.xsd + * + * @author Salva + * + */ +public interface RuleFilterAgent { + /** + * gets the selected options chosen by the user regarding the exclusion of + * CV mapping rules and object rules + * + * @return a hashMap in which the key is the identifier of the + * {@link UserCondition} and the value is the identifier of the + * chosen {@link UserOption} + */ + public HashMap getSelectedOptions(); + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterManager.java b/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterManager.java new file mode 100644 index 0000000..dd96b51 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/RuleFilterManager.java @@ -0,0 +1,545 @@ +package psidev.psi.ms.rulefilter; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; + +import psidev.psi.ms.ExtendedValidatorReport; +import psidev.psi.ms.rulefilter.jaxb.CvMappingRuleCondition; +import psidev.psi.ms.rulefilter.jaxb.CvMappingRuleToSkip; +import psidev.psi.ms.rulefilter.jaxb.MandatoryMzIdentMLElement; +import psidev.psi.ms.rulefilter.jaxb.MandatoryMzMLElement; +import psidev.psi.ms.rulefilter.jaxb.ObjectRuleCondition; +import psidev.psi.ms.rulefilter.jaxb.ObjectRuleToSkip; +import psidev.psi.ms.rulefilter.jaxb.ReferencedRules; +import psidev.psi.ms.rulefilter.jaxb.RuleFilter; +import psidev.psi.ms.rulefilter.jaxb.RulesToSkipRef; +import psidev.psi.ms.rulefilter.jaxb.UserCondition; +import psidev.psi.ms.rulefilter.jaxb.UserOption; +import psidev.psi.tools.validator.ValidatorMessage; +import psidev.psi.tools.validator.rules.codedrule.ObjectRule; +import psidev.psi.tools.validator.rules.cvmapping.CvRule; + +/** + * This class provides the methods to maintain a list of object rules and a list + * of cv mapping rules to skip. Its behaviour is configured by a configuration + * xml file (following the schema: + * http://proteo.cnb.csic.es/miape-api/schemas/ruleFilter_v1.2.xsd) + * + * @author Salva + * + */ +public class RuleFilterManager { + private JAXBContext jc; + private RuleFilter filter = null; + private List objectRulesToSkip = new ArrayList(); + private List cvMappingRulesToSkip = new ArrayList(); + + public RuleFilterManager(File xmlFile) throws JAXBException { + // check if null + if (xmlFile == null) + throw new IllegalArgumentException("Provide a no null file!"); + + // check if exists + if (!xmlFile.exists()) + throw new IllegalArgumentException(xmlFile.getAbsolutePath() + " doesn't exist!"); + jc = JAXBContext.newInstance("psidev.psi.ms.rulefilter.jaxb"); + this.filter = (RuleFilter) jc.createUnmarshaller().unmarshal(xmlFile); + + } + + public void setFilter(RuleFilter filter) { + this.filter = filter; + } + + public RuleFilter getFilter() { + return filter; + } + + /** + * Gets a list of mandatory elements + * + * @return + */ + public List getMandatoryElements() { + List ret = new ArrayList(); + if (filter.getMandatoryElements() != null) { + for (MandatoryMzIdentMLElement mandatoryElement : filter.getMandatoryElements() + .getMandatoryMzIdentMLElement()) { + final String mzIdentMLElement = mandatoryElement.getMzIdentMLElement(); + if (mzIdentMLElement != null && !"".equals(mzIdentMLElement)) + ret.add(mzIdentMLElement); + } + for (MandatoryMzMLElement mandatoryElement : filter.getMandatoryElements() + .getMandatoryMzMLElement()) { + final String mzMLElement = mandatoryElement.getMzMLElement(); + if (mzMLElement != null && !"".equals(mzMLElement)) + ret.add(mzMLElement); + } + } + return ret; + } + + /** + * Look for the chosen options in the rule filter file and returns a list + * with the identifiers of the rules to exclude + * + * @param selectedOptions + * : the key is the identifier of the condition and the value is + * the chosen option + * @return the list of identifiers of rules to exclude + */ + public Set getCVMappingRulesToSkipByUserOptions(HashMap selectedOptions) { + Set cvMappingRulesIds = new HashSet(); + + for (String conditionId : selectedOptions.keySet()) { + UserCondition userCondition = getCondition(conditionId); + if (userCondition != null) { + List rules = getMappingRulesToSkip(userCondition, + selectedOptions.get(conditionId)); + if (rules != null) { + for (CvMappingRuleToSkip cvMappingRule : rules) { + cvMappingRulesIds.add(cvMappingRule.getId()); + } + } + } + } + return cvMappingRulesIds; + } + + private List getMappingRulesToSkip(UserCondition userCondition, + String optionId) { + List cvMappingRulesToSkip = new ArrayList(); + if (optionId != null) + for (UserOption option : userCondition.getUserOption()) { + if (option.getId().equals(optionId)) { + if (option.getCvMappingRuleToSkip() != null) { + cvMappingRulesToSkip.addAll(option.getCvMappingRuleToSkip()); + } + if (option.getRulesToSkipRef() != null) { + for (RulesToSkipRef rulesToSkipRef : option.getRulesToSkipRef()) { + if (filter.getReferences() != null + && filter.getReferences().getReferencedRules() != null) { + for (ReferencedRules referencedRuleSet : filter.getReferences() + .getReferencedRules()) { + if (referencedRuleSet.getId().equals(rulesToSkipRef.getRef())) { + if (referencedRuleSet.getCvMappingRuleToSkip() != null) { + cvMappingRulesToSkip.addAll(referencedRuleSet + .getCvMappingRuleToSkip()); + } + } + } + } + } + } + } + } + return cvMappingRulesToSkip; + } + + private UserCondition getCondition(String conditionId) { + if (conditionId == null || "".equals(conditionId) || filter == null) + return null; + for (UserCondition userCondition : filter.getUserConditions().getUserCondition()) { + if (userCondition.getId().equals(conditionId)) + return userCondition; + } + return null; + } + + /** + * Look for the the chosen options in the rule filter file and returns a + * list with the identifiers of the rules to exclude + * + * @param selectedOptions + * : the key is the identifier of the condition and the value is + * the chosen option + * @return the list of identifiers of rules to exclude + */ + public Set getObjectRulesToSkipByUserOptions(HashMap selectedOptions) { + Set ret = new HashSet(); + + for (String conditionId : selectedOptions.keySet()) { + UserCondition condition = getCondition(conditionId); + if (condition != null) { + List rules = getObjectRulesToSkip(condition, + selectedOptions.get(conditionId)); + if (rules != null) { + for (ObjectRuleToSkip objectRule : rules) { + ret.add(objectRule.getId()); + } + } + } + } + + return ret; + } + + private List getObjectRulesToSkip(UserCondition condition, String optionId) { + List ret = new ArrayList(); + if (optionId != null) + for (UserOption option : condition.getUserOption()) { + if (option.getId().equals(optionId)) { + if (option.getObjectRuleToSkip() != null) { + ret.addAll(option.getObjectRuleToSkip()); + } + if (option.getRulesToSkipRef() != null) { + for (RulesToSkipRef ruleToSkipRef : option.getRulesToSkipRef()) { + if (filter.getReferences() != null + && filter.getReferences().getReferencedRules() != null) { + for (ReferencedRules referencedRuleSet : filter.getReferences() + .getReferencedRules()) { + if (referencedRuleSet.equals(ruleToSkipRef.getRef())) { + ret.addAll(referencedRuleSet.getObjectRuleToSkip()); + } + } + } + } + } + } + } + return ret; + } + + private List getObjectRulesToSkipByObjectRule(String ruleId, boolean valid) { + List ret = new ArrayList(); + + if (this.filter.getObjectRuleConditions() != null) { + for (ObjectRuleCondition objectRuleCondition : this.filter.getObjectRuleConditions() + .getObjectRuleCondition()) { + if (objectRuleCondition.getId().equals(ruleId)) { + if ((valid && objectRuleCondition.isValid()) + || (!valid && !objectRuleCondition.isValid())) { + if (objectRuleCondition.getObjectRuleToSkip() != null) { + for (ObjectRuleToSkip objectRule : objectRuleCondition + .getObjectRuleToSkip()) { + ret.add(objectRule.getId()); + } + } + } + } + } + } + return ret; + } + + private List getCvMappingRulesToSkipByObjectRule(String ruleId, boolean valid) { + List ret = new ArrayList(); + + if (this.filter.getObjectRuleConditions() != null) { + for (ObjectRuleCondition objectRuleCondition : this.filter.getObjectRuleConditions() + .getObjectRuleCondition()) { + if (objectRuleCondition.getId().equals(ruleId)) { + if ((valid && objectRuleCondition.isValid()) + || (!valid && !objectRuleCondition.isValid())) { + if (objectRuleCondition.getCvMappingRuleToSkip() != null) { + for (CvMappingRuleToSkip cvMappingRule : objectRuleCondition + .getCvMappingRuleToSkip()) { + ret.add(cvMappingRule.getId()); + } + } + } + } + } + } + return ret; + } + + public List getCvMappingRulesToSkipByCvMappingRule(String ruleId, boolean valid) { + List ret = new ArrayList(); + + if (this.filter.getCvMappingRuleConditions() != null) { + for (CvMappingRuleCondition cvMappingRule : this.filter.getCvMappingRuleConditions() + .getCvMappingRuleCondition()) { + if (cvMappingRule.getId().equals(ruleId)) { + if ((valid && cvMappingRule.isValid()) || (!valid && !cvMappingRule.isValid())) { + if (cvMappingRule.getCvMappingRuleToSkip() != null) { + for (CvMappingRuleToSkip cvMappingRule2 : cvMappingRule + .getCvMappingRuleToSkip()) { + ret.add(cvMappingRule2.getId()); + } + } + } + } + } + } + return ret; + } + + public List getObjectRulesToSkipByCvMappingRule(String ruleId, boolean valid) { + List ret = new ArrayList(); + + if (this.filter.getCvMappingRuleConditions() != null) { + for (CvMappingRuleCondition cvMappingRule : this.filter.getCvMappingRuleConditions() + .getCvMappingRuleCondition()) { + if (cvMappingRule.getId().equals(ruleId)) { + if ((valid && cvMappingRule.isValid()) || (!valid && !cvMappingRule.isValid())) { + if (cvMappingRule.getObjectRuleToSkip() != null) { + for (ObjectRuleToSkip objectRule : cvMappingRule.getObjectRuleToSkip()) { + ret.add(objectRule.getId()); + } + } + } + } + } + } + return ret; + } + + /** + * Add a collection of cv mapping rules identifiers to the list of cv + * mapping rules to skip + * + * @param cvMappingRulesIdentifiers + */ + public void addCvMappingRulesToSkip(Collection cvMappingRulesIdentifiers) { + for (String cvRuleIdentifier : cvMappingRulesIdentifiers) { + this.cvMappingRulesToSkip.add(cvRuleIdentifier); + } + } + + /** + * Add a collection of object rules identifiers to the list of object rules + * to skip + * + * @param objectRulesIdentifiers + */ + public void addObjectRulesToSkip(Collection objectRulesIdentifiers) { + for (String objectRuleIdentifier : objectRulesIdentifiers) { + this.objectRulesToSkip.add(objectRuleIdentifier); + } + } + + /** + * Add a CvRule to the collection of cv mapping rules to skip + * + * @param cvMappingRule + */ + public void addCvMappingRuleToSkip(CvRule cvMappingRule) { + this.cvMappingRulesToSkip.add(cvMappingRule.getId()); + } + + /** + * Add an object rule to the collection of object rules to skip + * + * @param objectRule + */ + public void addObjectRuleToSkip(ObjectRule objectRule) { + this.objectRulesToSkip.add(objectRule.getId()); + } + + /** + * Gets the list of identifiers of object rules to skip + * + * @return + */ + public List getObjectRulesToSkip() { + return objectRulesToSkip; + } + + /** + * Gets the list of identifiers of cv mapping rules to skip + * + * @return + */ + public List getCvMappingRulesToSkip() { + return cvMappingRulesToSkip; + } + + /** + * Check if it is necessary to add some rules to skip since the result of + * the execution of a cvRule + * + * @param rule + * @param valid + * if the rule has been passed or not + */ + public void updateRulesToSkipByCvMappingRuleResult(CvRule rule, boolean valid) { + // get cvMappingRules that should be skipped + final List cvMappingRulesToSkipByCvMappingRule = this + .getCvMappingRulesToSkipByCvMappingRule(rule.getId(), valid); + if (cvMappingRulesToSkipByCvMappingRule != null + && !cvMappingRulesToSkipByCvMappingRule.isEmpty()) + this.addCvMappingRulesToSkip(cvMappingRulesToSkipByCvMappingRule); + + // get objectRules that should be skipped + final List objectRulesToSkipByCvMappingRule = this + .getObjectRulesToSkipByCvMappingRule(rule.getId(), valid); + if (objectRulesToSkipByCvMappingRule != null && !objectRulesToSkipByCvMappingRule.isEmpty()) + this.addObjectRulesToSkip(objectRulesToSkipByCvMappingRule); + } + + /** + * Check if it is necessary to add some rules to skip since the result of + * the execution of a object rule + * + * @param rule + * @param valid + * if the rule has been passed or not + */ + public void updateRulesToSkipByObjectRuleResult(ObjectRule rule, boolean valid) { + // get objectRules that should be skipped + List objectRulesToSkip = this.getObjectRulesToSkipByObjectRule(rule.getId(), valid); + if (objectRulesToSkip != null && !objectRulesToSkip.isEmpty()) { + this.objectRulesToSkip.addAll(objectRulesToSkip); + } + // get cvMappingRules that should be skipped + List cvMappingRulesToSkip = this.getCvMappingRulesToSkipByObjectRule(rule.getId(), + valid); + if (cvMappingRulesToSkip != null && !cvMappingRulesToSkip.isEmpty()) { + this.cvMappingRulesToSkip.addAll(objectRulesToSkip); + } + + } + + /** + * Restarts the list of rules to skip + */ + public void restartRulesToSkip() { + // restart the rules to skip + this.objectRulesToSkip = new ArrayList(); + this.cvMappingRulesToSkip = new ArrayList(); + } + + /** + * Depending of the user selections some object and cvMapping rules will be + * tagged to be skipped in the validator + * + * @param selectedOptions + * a set of pairs key, value, where the key is the identifier of + * the condition and the value is the name of the chosen option + */ + public void filterRulesByUserOptions(HashMap selectedOptions) { + + // get cv mapping identifiers to exclude + this.addCvMappingRulesToSkip(getCVMappingRulesToSkipByUserOptions(selectedOptions)); + + // get object rules identifiers to exclude + this.addObjectRulesToSkip(getObjectRulesToSkipByUserOptions(selectedOptions)); + } + + /** + * Filters the list of ValidatorMessages checking each message with the + * lists of rules to skip and return the final list of messages + * + * @return the collection of validation messages after the filter + */ + public Collection filterValidatorMessages( + HashMap> msgs, ExtendedValidatorReport extendedReport) { + ArrayList finalMessages = new ArrayList(); + + // for each message, check if the rule that generated it is in the list + // of rules to skip + if (msgs != null && !msgs.isEmpty()) { + + for (String ruleIdentifier : msgs.keySet()) { + boolean report = true; + // if the rule that generated the messages is in the list of + // rules to skip, not add to the final message list + if (this.getObjectRulesToSkip() != null + && this.getObjectRulesToSkip().contains(ruleIdentifier)) + report = false; + + // if the rule that generated the messages is in the list of + // rules to skip, not add to the final message list + if (this.getCvMappingRulesToSkip() != null + && this.getCvMappingRulesToSkip().contains(ruleIdentifier)) + report = false; + + if (report) { + finalMessages.addAll(msgs.get(ruleIdentifier)); + } else { + // move the rule to the list of non checked rules + extendedReport.setObjectRuleAsSkipped(ruleIdentifier); + } + } + } + return finalMessages; + } + + public void printRuleFilter() { + for (UserCondition condition : filter.getUserConditions().getUserCondition()) { + System.out.println("\nCondition: " + condition.getId()); + for (UserOption option : condition.getUserOption()) { + System.out.println("\tOption " + option.getId()); + for (CvMappingRuleToSkip cvMappingRule : option.getCvMappingRuleToSkip()) { + System.out.println("\t\tmapping rule id: " + cvMappingRule.getId()); + } + for (ObjectRuleToSkip objectRule : option.getObjectRuleToSkip()) { + System.out.println("\t\tobject rule id: " + objectRule.getId()); + } + if (option.getRulesToSkipRef() != null) { + for (RulesToSkipRef ruleSetReference : option.getRulesToSkipRef()) { + if (filter.getReferences() != null) { + for (ReferencedRules referencedRuleSet : filter.getReferences() + .getReferencedRules()) { + if (referencedRuleSet.getId().equals(ruleSetReference.getRef())) { + for (CvMappingRuleToSkip cvMappingRule : referencedRuleSet + .getCvMappingRuleToSkip()) { + System.out.println("\t\tmapping rule id: " + + cvMappingRule.getId()); + } + for (ObjectRuleToSkip objectRule : referencedRuleSet + .getObjectRuleToSkip()) { + System.out.println("\t\tobject rule id: " + + objectRule.getId()); + } + } + } + } + } + } + } + } + if (filter.getObjectRuleConditions() != null) { + System.out.println("\nObjectRuleConditions:"); + for (ObjectRuleCondition objectRuleCondition : filter.getObjectRuleConditions() + .getObjectRuleCondition()) { + System.out.println("\tObject rule condition: " + objectRuleCondition.getId() + + " isValid: " + objectRuleCondition.isValid()); + for (ObjectRuleToSkip objectRule : objectRuleCondition.getObjectRuleToSkip()) { + System.out.println("\t\tobject rule to skip: " + objectRule.getId()); + } + for (CvMappingRuleToSkip cvMappingRule : objectRuleCondition + .getCvMappingRuleToSkip()) { + System.out.println("\t\tcvMapping rule to skip: " + cvMappingRule.getId()); + } + } + } + if (filter.getCvMappingRuleConditions() != null) { + System.out.println("\ncvMappingRuleConditions:"); + for (CvMappingRuleCondition cvMappingCondition : filter.getCvMappingRuleConditions() + .getCvMappingRuleCondition()) { + System.out.println("\tcvMapping rule condition: " + cvMappingCondition.getId() + + " isValid: " + cvMappingCondition.isValid()); + for (ObjectRuleToSkip objectRule : cvMappingCondition.getObjectRuleToSkip()) { + System.out.println("\t\tobject rule to skip: " + objectRule.getId()); + } + for (CvMappingRuleToSkip cvMappingRule : cvMappingCondition + .getCvMappingRuleToSkip()) { + System.out.println("\t\tcvMapping rule to skip: " + cvMappingRule.getId()); + } + } + } + if (filter.getMandatoryElements() != null) { + System.out.println("\nMandatory elements:"); + for (MandatoryMzMLElement mandatorymzMLElement : filter.getMandatoryElements() + .getMandatoryMzMLElement()) { + System.out.println("\tMandatory mzML element: " + + mandatorymzMLElement.getMzMLElement()); + } + for (MandatoryMzIdentMLElement mandatorymzIdentMLElement : filter + .getMandatoryElements().getMandatoryMzIdentMLElement()) { + System.out.println("\tMandatory mzIdentML element: " + + mandatorymzIdentMLElement.getMzIdentMLElement()); + } + } + } +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleCondition.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleCondition.java new file mode 100644 index 0000000..e10b613 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleCondition.java @@ -0,0 +1,155 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}objectRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{}cvMappingRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="valid" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "objectRuleToSkip", + "cvMappingRuleToSkip" +}) +@XmlRootElement(name = "cvMappingRuleCondition") +public class CvMappingRuleCondition { + + protected List objectRuleToSkip; + protected List cvMappingRuleToSkip; + @XmlAttribute(name = "id", required = true) + protected String id; + @XmlAttribute(name = "valid", required = true) + protected boolean valid; + + /** + * Gets the value of the objectRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the objectRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getObjectRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ObjectRuleToSkip } + * + * + */ + public List getObjectRuleToSkip() { + if (objectRuleToSkip == null) { + objectRuleToSkip = new ArrayList(); + } + return this.objectRuleToSkip; + } + + /** + * Gets the value of the cvMappingRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvMappingRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvMappingRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CvMappingRuleToSkip } + * + * + */ + public List getCvMappingRuleToSkip() { + if (cvMappingRuleToSkip == null) { + cvMappingRuleToSkip = new ArrayList(); + } + return this.cvMappingRuleToSkip; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the valid property. + * + */ + public boolean isValid() { + return valid; + } + + /** + * Sets the value of the valid property. + * + */ + public void setValid(boolean value) { + this.valid = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleConditions.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleConditions.java new file mode 100644 index 0000000..7c7eb69 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleConditions.java @@ -0,0 +1,78 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}cvMappingRuleCondition" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "cvMappingRuleCondition" +}) +@XmlRootElement(name = "cvMappingRuleConditions") +public class CvMappingRuleConditions { + + @XmlElement(required = true) + protected List cvMappingRuleCondition; + + /** + * Gets the value of the cvMappingRuleCondition property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvMappingRuleCondition property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvMappingRuleCondition().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CvMappingRuleCondition } + * + * + */ + public List getCvMappingRuleCondition() { + if (cvMappingRuleCondition == null) { + cvMappingRuleCondition = new ArrayList(); + } + return this.cvMappingRuleCondition; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleToSkip.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleToSkip.java new file mode 100644 index 0000000..9105485 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/CvMappingRuleToSkip.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "cvMappingRuleToSkip") +public class CvMappingRuleToSkip { + + @XmlAttribute(name = "id", required = true) + protected String id; + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryElements.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryElements.java new file mode 100644 index 0000000..66fc659 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryElements.java @@ -0,0 +1,108 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice>
+ *         <element ref="{}mandatoryMzIdentMLElement" maxOccurs="unbounded"/>
+ *         <element ref="{}mandatoryMzMLElement" maxOccurs="unbounded"/>
+ *       </choice>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "mandatoryMzIdentMLElement", + "mandatoryMzMLElement" +}) +@XmlRootElement(name = "mandatoryElements") +public class MandatoryElements { + + protected List mandatoryMzIdentMLElement; + protected List mandatoryMzMLElement; + + /** + * Gets the value of the mandatoryMzIdentMLElement property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the mandatoryMzIdentMLElement property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getMandatoryMzIdentMLElement().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MandatoryMzIdentMLElement } + * + * + */ + public List getMandatoryMzIdentMLElement() { + if (mandatoryMzIdentMLElement == null) { + mandatoryMzIdentMLElement = new ArrayList(); + } + return this.mandatoryMzIdentMLElement; + } + + /** + * Gets the value of the mandatoryMzMLElement property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the mandatoryMzMLElement property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getMandatoryMzMLElement().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MandatoryMzMLElement } + * + * + */ + public List getMandatoryMzMLElement() { + if (mandatoryMzMLElement == null) { + mandatoryMzMLElement = new ArrayList(); + } + return this.mandatoryMzMLElement; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzIdentMLElement.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzIdentMLElement.java new file mode 100644 index 0000000..f493f80 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzIdentMLElement.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="mzIdentMLElement" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "mandatoryMzIdentMLElement") +public class MandatoryMzIdentMLElement { + + @XmlAttribute(name = "mzIdentMLElement", required = true) + protected String mzIdentMLElement; + + /** + * Gets the value of the mzIdentMLElement property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMzIdentMLElement() { + return mzIdentMLElement; + } + + /** + * Sets the value of the mzIdentMLElement property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMzIdentMLElement(String value) { + this.mzIdentMLElement = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzMLElement.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzMLElement.java new file mode 100644 index 0000000..57397ec --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/MandatoryMzMLElement.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="mzMLElement" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "mandatoryMzMLElement") +public class MandatoryMzMLElement { + + @XmlAttribute(name = "mzMLElement", required = true) + protected String mzMLElement; + + /** + * Gets the value of the mzMLElement property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMzMLElement() { + return mzMLElement; + } + + /** + * Sets the value of the mzMLElement property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMzMLElement(String value) { + this.mzMLElement = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectFactory.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectFactory.java new file mode 100644 index 0000000..1ecc6f7 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectFactory.java @@ -0,0 +1,167 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the psidev.psi.ms.rulefilter.jaxb package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: psidev.psi.ms.rulefilter.jaxb + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link UserConditions } + * + */ + public UserConditions createUserConditions() { + return new UserConditions(); + } + + /** + * Create an instance of {@link UserOption } + * + */ + public UserOption createUserOption() { + return new UserOption(); + } + + /** + * Create an instance of {@link RulesToSkipRef } + * + */ + public RulesToSkipRef createRulesToSkipRef() { + return new RulesToSkipRef(); + } + + /** + * Create an instance of {@link ObjectRuleToSkip } + * + */ + public ObjectRuleToSkip createObjectRuleToSkip() { + return new ObjectRuleToSkip(); + } + + /** + * Create an instance of {@link CvMappingRuleCondition } + * + */ + public CvMappingRuleCondition createCvMappingRuleCondition() { + return new CvMappingRuleCondition(); + } + + /** + * Create an instance of {@link MandatoryMzIdentMLElement } + * + */ + public MandatoryMzIdentMLElement createMandatoryMzIdentMLElement() { + return new MandatoryMzIdentMLElement(); + } + + /** + * Create an instance of {@link CvMappingRuleToSkip } + * + */ + public CvMappingRuleToSkip createCvMappingRuleToSkip() { + return new CvMappingRuleToSkip(); + } + + /** + * Create an instance of {@link RuleFilter } + * + */ + public RuleFilter createRuleFilter() { + return new RuleFilter(); + } + + /** + * Create an instance of {@link ObjectRuleCondition } + * + */ + public ObjectRuleCondition createObjectRuleCondition() { + return new ObjectRuleCondition(); + } + + /** + * Create an instance of {@link ObjectRuleConditions } + * + */ + public ObjectRuleConditions createObjectRuleConditions() { + return new ObjectRuleConditions(); + } + + /** + * Create an instance of {@link UserCondition } + * + */ + public UserCondition createUserCondition() { + return new UserCondition(); + } + + /** + * Create an instance of {@link MandatoryElements } + * + */ + public MandatoryElements createMandatoryElements() { + return new MandatoryElements(); + } + + /** + * Create an instance of {@link CvMappingRuleConditions } + * + */ + public CvMappingRuleConditions createCvMappingRuleConditions() { + return new CvMappingRuleConditions(); + } + + /** + * Create an instance of {@link References } + * + */ + public References createReferences() { + return new References(); + } + + /** + * Create an instance of {@link MandatoryMzMLElement } + * + */ + public MandatoryMzMLElement createMandatoryMzMLElement() { + return new MandatoryMzMLElement(); + } + + /** + * Create an instance of {@link ReferencedRules } + * + */ + public ReferencedRules createReferencedRules() { + return new ReferencedRules(); + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleCondition.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleCondition.java new file mode 100644 index 0000000..55e166e --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleCondition.java @@ -0,0 +1,155 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}objectRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{}cvMappingRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="valid" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "objectRuleToSkip", + "cvMappingRuleToSkip" +}) +@XmlRootElement(name = "objectRuleCondition") +public class ObjectRuleCondition { + + protected List objectRuleToSkip; + protected List cvMappingRuleToSkip; + @XmlAttribute(name = "id", required = true) + protected String id; + @XmlAttribute(name = "valid", required = true) + protected boolean valid; + + /** + * Gets the value of the objectRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the objectRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getObjectRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ObjectRuleToSkip } + * + * + */ + public List getObjectRuleToSkip() { + if (objectRuleToSkip == null) { + objectRuleToSkip = new ArrayList(); + } + return this.objectRuleToSkip; + } + + /** + * Gets the value of the cvMappingRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvMappingRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvMappingRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CvMappingRuleToSkip } + * + * + */ + public List getCvMappingRuleToSkip() { + if (cvMappingRuleToSkip == null) { + cvMappingRuleToSkip = new ArrayList(); + } + return this.cvMappingRuleToSkip; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the valid property. + * + */ + public boolean isValid() { + return valid; + } + + /** + * Sets the value of the valid property. + * + */ + public void setValid(boolean value) { + this.valid = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleConditions.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleConditions.java new file mode 100644 index 0000000..b8909ca --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleConditions.java @@ -0,0 +1,78 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}objectRuleCondition" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "objectRuleCondition" +}) +@XmlRootElement(name = "objectRuleConditions") +public class ObjectRuleConditions { + + @XmlElement(required = true) + protected List objectRuleCondition; + + /** + * Gets the value of the objectRuleCondition property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the objectRuleCondition property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getObjectRuleCondition().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ObjectRuleCondition } + * + * + */ + public List getObjectRuleCondition() { + if (objectRuleCondition == null) { + objectRuleCondition = new ArrayList(); + } + return this.objectRuleCondition; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleToSkip.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleToSkip.java new file mode 100644 index 0000000..5e370a6 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ObjectRuleToSkip.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "objectRuleToSkip") +public class ObjectRuleToSkip { + + @XmlAttribute(name = "id", required = true) + protected String id; + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ReferencedRules.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ReferencedRules.java new file mode 100644 index 0000000..edab6fa --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/ReferencedRules.java @@ -0,0 +1,138 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}cvMappingRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{}objectRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "cvMappingRuleToSkip", + "objectRuleToSkip" +}) +@XmlRootElement(name = "referencedRules") +public class ReferencedRules { + + protected List cvMappingRuleToSkip; + protected List objectRuleToSkip; + @XmlAttribute(name = "id", required = true) + @XmlSchemaType(name = "anySimpleType") + protected String id; + + /** + * Gets the value of the cvMappingRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvMappingRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvMappingRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CvMappingRuleToSkip } + * + * + */ + public List getCvMappingRuleToSkip() { + if (cvMappingRuleToSkip == null) { + cvMappingRuleToSkip = new ArrayList(); + } + return this.cvMappingRuleToSkip; + } + + /** + * Gets the value of the objectRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the objectRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getObjectRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ObjectRuleToSkip } + * + * + */ + public List getObjectRuleToSkip() { + if (objectRuleToSkip == null) { + objectRuleToSkip = new ArrayList(); + } + return this.objectRuleToSkip; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/References.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/References.java new file mode 100644 index 0000000..d0fc87e --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/References.java @@ -0,0 +1,78 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}referencedRules" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "referencedRules" +}) +@XmlRootElement(name = "references") +public class References { + + @XmlElement(required = true) + protected List referencedRules; + + /** + * Gets the value of the referencedRules property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the referencedRules property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReferencedRules().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ReferencedRules } + * + * + */ + public List getReferencedRules() { + if (referencedRules == null) { + referencedRules = new ArrayList(); + } + return this.referencedRules; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RuleFilter.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RuleFilter.java new file mode 100644 index 0000000..388aab9 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RuleFilter.java @@ -0,0 +1,179 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}userConditions"/>
+ *         <element ref="{}objectRuleConditions" minOccurs="0"/>
+ *         <element ref="{}cvMappingRuleConditions" minOccurs="0"/>
+ *         <element ref="{}references" minOccurs="0"/>
+ *         <element ref="{}mandatoryElements" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "userConditions", + "objectRuleConditions", + "cvMappingRuleConditions", + "references", + "mandatoryElements" +}) +@XmlRootElement(name = "ruleFilter") +public class RuleFilter { + + @XmlElement(required = true) + protected UserConditions userConditions; + protected ObjectRuleConditions objectRuleConditions; + protected CvMappingRuleConditions cvMappingRuleConditions; + protected References references; + protected MandatoryElements mandatoryElements; + + /** + * Gets the value of the userConditions property. + * + * @return + * possible object is + * {@link UserConditions } + * + */ + public UserConditions getUserConditions() { + return userConditions; + } + + /** + * Sets the value of the userConditions property. + * + * @param value + * allowed object is + * {@link UserConditions } + * + */ + public void setUserConditions(UserConditions value) { + this.userConditions = value; + } + + /** + * Gets the value of the objectRuleConditions property. + * + * @return + * possible object is + * {@link ObjectRuleConditions } + * + */ + public ObjectRuleConditions getObjectRuleConditions() { + return objectRuleConditions; + } + + /** + * Sets the value of the objectRuleConditions property. + * + * @param value + * allowed object is + * {@link ObjectRuleConditions } + * + */ + public void setObjectRuleConditions(ObjectRuleConditions value) { + this.objectRuleConditions = value; + } + + /** + * Gets the value of the cvMappingRuleConditions property. + * + * @return + * possible object is + * {@link CvMappingRuleConditions } + * + */ + public CvMappingRuleConditions getCvMappingRuleConditions() { + return cvMappingRuleConditions; + } + + /** + * Sets the value of the cvMappingRuleConditions property. + * + * @param value + * allowed object is + * {@link CvMappingRuleConditions } + * + */ + public void setCvMappingRuleConditions(CvMappingRuleConditions value) { + this.cvMappingRuleConditions = value; + } + + /** + * Gets the value of the references property. + * + * @return + * possible object is + * {@link References } + * + */ + public References getReferences() { + return references; + } + + /** + * Sets the value of the references property. + * + * @param value + * allowed object is + * {@link References } + * + */ + public void setReferences(References value) { + this.references = value; + } + + /** + * Gets the value of the mandatoryElements property. + * + * @return + * possible object is + * {@link MandatoryElements } + * + */ + public MandatoryElements getMandatoryElements() { + return mandatoryElements; + } + + /** + * Sets the value of the mandatoryElements property. + * + * @param value + * allowed object is + * {@link MandatoryElements } + * + */ + public void setMandatoryElements(MandatoryElements value) { + this.mandatoryElements = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RulesToSkipRef.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RulesToSkipRef.java new file mode 100644 index 0000000..39795a9 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/RulesToSkipRef.java @@ -0,0 +1,67 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="ref" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "rulesToSkipRef") +public class RulesToSkipRef { + + @XmlAttribute(name = "ref", required = true) + protected String ref; + + /** + * Gets the value of the ref property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRef() { + return ref; + } + + /** + * Sets the value of the ref property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRef(String value) { + this.ref = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserCondition.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserCondition.java new file mode 100644 index 0000000..bbcbfab --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserCondition.java @@ -0,0 +1,106 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}userOption" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "userOption" +}) +@XmlRootElement(name = "userCondition") +public class UserCondition { + + @XmlElement(required = true) + protected List userOption; + @XmlAttribute(name = "id", required = true) + protected String id; + + /** + * Gets the value of the userOption property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the userOption property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getUserOption().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link UserOption } + * + * + */ + public List getUserOption() { + if (userOption == null) { + userOption = new ArrayList(); + } + return this.userOption; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserConditions.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserConditions.java new file mode 100644 index 0000000..2e70f1a --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserConditions.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}userCondition" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "userCondition" +}) +@XmlRootElement(name = "userConditions") +public class UserConditions { + + protected List userCondition; + + /** + * Gets the value of the userCondition property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the userCondition property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getUserCondition().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link UserCondition } + * + * + */ + public List getUserCondition() { + if (userCondition == null) { + userCondition = new ArrayList(); + } + return this.userCondition; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserOption.java b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserOption.java new file mode 100644 index 0000000..631b377 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/rulefilter/jaxb/UserOption.java @@ -0,0 +1,168 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.2-7 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.01.02 at 01:22:10 PM CET +// + + +package psidev.psi.ms.rulefilter.jaxb; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}cvMappingRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{}objectRuleToSkip" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{}rulesToSkipRef" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "cvMappingRuleToSkip", + "objectRuleToSkip", + "rulesToSkipRef" +}) +@XmlRootElement(name = "userOption") +public class UserOption { + + protected List cvMappingRuleToSkip; + protected List objectRuleToSkip; + protected List rulesToSkipRef; + @XmlAttribute(name = "id", required = true) + protected String id; + + /** + * Gets the value of the cvMappingRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the cvMappingRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCvMappingRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link CvMappingRuleToSkip } + * + * + */ + public List getCvMappingRuleToSkip() { + if (cvMappingRuleToSkip == null) { + cvMappingRuleToSkip = new ArrayList(); + } + return this.cvMappingRuleToSkip; + } + + /** + * Gets the value of the objectRuleToSkip property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the objectRuleToSkip property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getObjectRuleToSkip().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ObjectRuleToSkip } + * + * + */ + public List getObjectRuleToSkip() { + if (objectRuleToSkip == null) { + objectRuleToSkip = new ArrayList(); + } + return this.objectRuleToSkip; + } + + /** + * Gets the value of the rulesToSkipRef property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the rulesToSkipRef property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getRulesToSkipRef().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link RulesToSkipRef } + * + * + */ + public List getRulesToSkipRef() { + if (rulesToSkipRef == null) { + rulesToSkipRef = new ArrayList(); + } + return this.rulesToSkipRef; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + +} diff --git a/validator/src/main/java/psidev/psi/ms/swingworker/SwingWorker.java b/validator/src/main/java/psidev/psi/ms/swingworker/SwingWorker.java new file mode 100644 index 0000000..b2641e6 --- /dev/null +++ b/validator/src/main/java/psidev/psi/ms/swingworker/SwingWorker.java @@ -0,0 +1,150 @@ +/** + * Created by IntelliJ IDEA. + * User: martlenn + * Date: 30-Aug-2007 + * Time: 12:26:58 + */ +package psidev.psi.ms.swingworker; + +import javax.swing.*; + +/* + * CVS information: + * + * $Revision$ + * $Date$ + */ + +/** + * This is the 3rd version of SwingWorker (also known as + * SwingWorker 3), an abstract class that you subclass to + * perform GUI-related work in a dedicated thread. For + * instructions on and examples of using this class, see: + * + * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html + * + * Note that the API changed slightly in the 3rd version: + * You must now invoke start() on the SwingWorker after + * creating it. + */ +public abstract class SwingWorker { + private Object value; // see getValue(), setValue() + + /** + * Class to maintain reference to current worker thread + * under separate synchronization control. + */ + private static class ThreadVar { + private Thread thread; + ThreadVar(Thread t) { thread = t; } + synchronized Thread get() { return thread; } + synchronized void clear() { thread = null; } + } + + private ThreadVar threadVar; + + /** + * Get the value produced by the worker thread, or null if it + * hasn't been constructed yet. + */ + protected synchronized Object getValue() { + return value; + } + + /** + * Set the value produced by worker thread + */ + private synchronized void setValue(Object x) { + value = x; + } + + /** + * Compute the value to be returned by the get method. + */ + public abstract Object construct(); + + /** + * Called on the event dispatching thread (not on the worker thread) + * after the construct method has returned. + */ + public void finished() { + } + + /** + * A new method that interrupts the worker thread. Call this method + * to force the worker to stop what it's doing. + */ + public void interrupt() { + Thread t = threadVar.get(); + if (t != null) { + t.interrupt(); + } + threadVar.clear(); + } + + /** + * Return the value created by the construct method. + * Returns null if either the constructing thread or the current + * thread was interrupted before a value was produced. + * + * @return the value created by the construct method + */ + public Object get() { + while (true) { + Thread t = threadVar.get(); + if (t == null) { + return getValue(); + } + try { + t.join(); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); // propagate + return null; + } + } + } + + + /** + * Start a thread that will call the construct method + * and then exit. + */ + public SwingWorker() { + final Runnable doFinished = new Runnable() { + public void run() { finished(); } + }; + + + Runnable doConstruct = new Runnable() { + public void run() { + try { + setValue(construct()); + if(Thread.currentThread().isInterrupted()) { + return; + } + } + finally { + threadVar.clear(); + } + SwingUtilities.invokeLater(doFinished); + } + }; + + Thread t = new Thread(doConstruct); + threadVar = new ThreadVar(t); + } + + /** + * Start the worker thread. + */ + public void start() { + Thread t = threadVar.get(); + if (t != null) { + if (!t.isInterrupted()) { + t.start(); + } + } + } + +} diff --git a/validator/src/main/resources/ObjectRules.xml b/validator/src/main/resources/ObjectRules.xml new file mode 100644 index 0000000..accc108 --- /dev/null +++ b/validator/src/main/resources/ObjectRules.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/validator/src/main/resources/ObjectRulesMIAPE.xml b/validator/src/main/resources/ObjectRulesMIAPE.xml new file mode 100644 index 0000000..d6e8fc4 --- /dev/null +++ b/validator/src/main/resources/ObjectRulesMIAPE.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/validator/src/main/resources/defaultMzMLElement.cfg.xml b/validator/src/main/resources/defaultMzMLElement.cfg.xml new file mode 100644 index 0000000..71945b1 --- /dev/null +++ b/validator/src/main/resources/defaultMzMLElement.cfg.xml @@ -0,0 +1,429 @@ + + + + + + + + + + + + + + + + + analyzer + true + /mzML/instrumentConfigurationList/instrumentConfiguration/componentList/analyzer + false + uk.ac.ebi.jmzml.model.mzml.AnalyzerComponent + false + + + binaryDataArray + false + false + uk.ac.ebi.jmzml.model.mzml.BinaryDataArray + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.BinaryDataArrayRefResolver + + + binaryDataArrayList + false + false + uk.ac.ebi.jmzml.model.mzml.BinaryDataArrayList + false + + + chromatogram + true + /mzML/run/chromatogramList/chromatogram + true + uk.ac.ebi.jmzml.model.mzml.Chromatogram + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.ChromatogramRefResolver + + + chromatogramList + true + /mzML/run/chromatogramList + false + uk.ac.ebi.jmzml.model.mzml.ChromatogramList + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.ChromatogramListRefResolver + + + component + false + false + uk.ac.ebi.jmzml.model.mzml.Component + false + + + componentList + true + /mzML/instrumentConfigurationList/instrumentConfiguration/componentList + false + uk.ac.ebi.jmzml.model.mzml.ComponentList + false + + + cv + true + /mzML/cvList/cv + true + uk.ac.ebi.jmzml.model.mzml.CV + false + + + cvList + true + /mzML/cvList + false + uk.ac.ebi.jmzml.model.mzml.CVList + false + + + cvParam + false + false + uk.ac.ebi.jmzml.model.mzml.CVParam + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.CVParamRefResolver + + + dataProcessing + true + /mzML/dataProcessingList/dataProcessing + true + uk.ac.ebi.jmzml.model.mzml.DataProcessing + false + + + dataProcessingList + true + /mzML/dataProcessingList + false + uk.ac.ebi.jmzml.model.mzml.DataProcessingList + false + + + detector + true + /mzML/instrumentConfigurationList/instrumentConfiguration/componentList/detector + false + uk.ac.ebi.jmzml.model.mzml.DetectorComponent + false + + + fileDescription + true + /mzML/fileDescription + false + uk.ac.ebi.jmzml.model.mzml.FileDescription + false + + + index + true + /indexedmzML/indexList/index + false + uk.ac.ebi.jmzml.model.mzml.Index + false + + + indexedmzML + true + /indexedmzML + false + uk.ac.ebi.jmzml.model.mzml.IndexedmzML + false + + + indexList + true + /indexedmzML/indexList + false + uk.ac.ebi.jmzml.model.mzml.IndexList + false + + + instrumentConfiguration + true + /mzML/instrumentConfigurationList/instrumentConfiguration + true + uk.ac.ebi.jmzml.model.mzml.InstrumentConfiguration + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.InstrumentConfigurationRefResolver + + + instrumentConfigurationList + true + /mzML/instrumentConfigurationList + false + uk.ac.ebi.jmzml.model.mzml.InstrumentConfigurationList + false + + + mzML + true + /mzML + false + uk.ac.ebi.jmzml.model.mzml.MzML + false + + + offset + true + /indexedmzML/indexList/index/offset + false + uk.ac.ebi.jmzml.model.mzml.Offset + false + + + paramGroup + false + false + uk.ac.ebi.jmzml.model.mzml.ParamGroup + false + + + precursor + true + /mzML/run/spectrumList/spectrum/precursorList/precursor + false + uk.ac.ebi.jmzml.model.mzml.Precursor + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.PrecursorRefResolver + + + precursorList + true + /mzML/run/spectrumList/spectrum/precursorList + false + uk.ac.ebi.jmzml.model.mzml.PrecursorList + false + + + processingMethod + true + /mzML/dataProcessingList/dataProcessing/processingMethod + false + uk.ac.ebi.jmzml.model.mzml.ProcessingMethod + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.ProcessingMethodRefResolver + + + product + true + /mzML/run/spectrumList/spectrum/productList/product + false + uk.ac.ebi.jmzml.model.mzml.Product + false + + + productList + true + /mzML/run/spectrumList/spectrum/productList + false + uk.ac.ebi.jmzml.model.mzml.ProductList + false + + + referenceableParamGroup + true + /mzML/referenceableParamGroupList/referenceableParamGroup + true + uk.ac.ebi.jmzml.model.mzml.ReferenceableParamGroup + false + + + referenceableParamGroupList + true + /mzML/referenceableParamGroupList + false + uk.ac.ebi.jmzml.model.mzml.ReferenceableParamGroupList + false + + + referenceableParamGroupRef + false + false + uk.ac.ebi.jmzml.model.mzml.ReferenceableParamGroupRef + true + uk.ac.ebi.jmzml.xml.jaxb.resolver.ReferenceableParamGroupRefResolver + + + run + true + /mzML/run + true + uk.ac.ebi.jmzml.model.mzml.Run + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.RunRefResolver + + + sample + true + /mzML/sampleList/sample + true + uk.ac.ebi.jmzml.model.mzml.Sample + false + + + sampleList + true + /mzML/sampleList + false + uk.ac.ebi.jmzml.model.mzml.SampleList + false + + + scan + true + /mzML/run/spectrumList/spectrum/scanList/scan + false + uk.ac.ebi.jmzml.model.mzml.Scan + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.ScanRefResolver + + + scanList + true + /mzML/run/spectrumList/spectrum/scanList + false + uk.ac.ebi.jmzml.model.mzml.ScanList + false + + + scanSettings + true + /mzML/scanSettingsList/scanSettings + true + uk.ac.ebi.jmzml.model.mzml.ScanSettings + false + + + scanSettingsList + true + /mzML/scanSettingsList + false + uk.ac.ebi.jmzml.model.mzml.ScanSettingsList + false + + + scanWindowList + true + /mzML/run/spectrumList/spectrum/scanList/scan/scanWindowList + false + uk.ac.ebi.jmzml.model.mzml.ScanWindowList + false + + + selectedIonList + true + /mzML/run/spectrumList/spectrum/precursorList/precursor/selectedIonList + false + uk.ac.ebi.jmzml.model.mzml.SelectedIonList + false + + + software + true + /mzML/softwareList/software + true + uk.ac.ebi.jmzml.model.mzml.Software + false + + + softwareList + true + /mzML/softwareList + false + uk.ac.ebi.jmzml.model.mzml.SoftwareList + false + + + softwareRef + false + false + uk.ac.ebi.jmzml.model.mzml.SoftwareRef + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.SoftwareRefResolver + + + sourceComponent + true + /mzML/instrumentConfigurationList/instrumentConfiguration/componentList/source + false + uk.ac.ebi.jmzml.model.mzml.SourceComponent + false + + + sourceFile + true + /mzML/fileDescription/sourceFileList/sourceFile + true + uk.ac.ebi.jmzml.model.mzml.SourceFile + false + + + sourceFileList + true + /mzML/fileDescription/sourceFileList + false + uk.ac.ebi.jmzml.model.mzml.SourceFileList + false + + + sourceFileRefList + false + false + uk.ac.ebi.jmzml.model.mzml.SourceFileRefList + false + + + sourceFileRef + false + false + uk.ac.ebi.jmzml.model.mzml.SourceFileRef + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.SourceFileRefResolver + + + spectrum + true + /mzML/run/spectrumList/spectrum + true + uk.ac.ebi.jmzml.model.mzml.Spectrum + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.SpectrumRefResolver + + + spectrumList + true + /mzML/run/spectrumList + false + uk.ac.ebi.jmzml.model.mzml.SpectrumList + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.SpectrumListRefResolver + + + targetList + true + /mzML/scanSettingsList/scanSettings/targetList + false + uk.ac.ebi.jmzml.model.mzml.TargetList + false + + + userParam + false + false + uk.ac.ebi.jmzml.model.mzml.UserParam + false + uk.ac.ebi.jmzml.xml.jaxb.resolver.UserParamRefResolver + + diff --git a/validator/src/main/resources/log4j.properties b/validator/src/main/resources/log4j.properties new file mode 100644 index 0000000..17bb691 --- /dev/null +++ b/validator/src/main/resources/log4j.properties @@ -0,0 +1,7 @@ +# Set root to dump to console +log4j.rootCategory=WARN, console + +# console is set to be a console appender and uses patternlayout. +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=%d %p %c{1} - %m%n diff --git a/validator/src/main/resources/miape-ms-rules.xml b/validator/src/main/resources/miape-ms-rules.xml new file mode 100644 index 0000000..65777f3 --- /dev/null +++ b/validator/src/main/resources/miape-ms-rules.xml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/validator/src/main/resources/ms-mapping.xml b/validator/src/main/resources/ms-mapping.xml new file mode 100644 index 0000000..7a3e9cf --- /dev/null +++ b/validator/src/main/resources/ms-mapping.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/validator/src/main/resources/ontologies.xml b/validator/src/main/resources/ontologies.xml new file mode 100644 index 0000000..4db55c9 --- /dev/null +++ b/validator/src/main/resources/ontologies.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/validator/src/main/resources/ruleFilterMIAPE.xml b/validator/src/main/resources/ruleFilterMIAPE.xml new file mode 100644 index 0000000..90b6cfd --- /dev/null +++ b/validator/src/main/resources/ruleFilterMIAPE.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/validator/src/main/resources/validation.properties b/validator/src/main/resources/validation.properties new file mode 100644 index 0000000..998668a --- /dev/null +++ b/validator/src/main/resources/validation.properties @@ -0,0 +1,6 @@ +mapping.rule.file.semantic.validation = ms-mapping.xml +mapping.rule.file.miape.validation = miape-ms-rules.xml +object.rule.file.semantic.validation = ObjectRules.xml +object.rule.file.miape.validation = ObjectRulesMIAPE.xml +ontologies.file = ontologies.xml +miape.filter.rule.file = ruleFilterMIAPE.xml diff --git a/validator/src/test/java/psidev/psi/ms/rulefilter/RuleFilterTest.java b/validator/src/test/java/psidev/psi/ms/rulefilter/RuleFilterTest.java new file mode 100644 index 0000000..024f301 --- /dev/null +++ b/validator/src/test/java/psidev/psi/ms/rulefilter/RuleFilterTest.java @@ -0,0 +1,56 @@ +package psidev.psi.ms.rulefilter; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import psidev.psi.ms.Resources; + +import javax.xml.bind.JAXBException; +import java.io.File; +import java.util.HashMap; +import java.util.Set; + +import static org.junit.Assert.fail; + +public class RuleFilterTest { + + private static final String FILE_RULE_FILTER = "/ruleFilterMIAPE.xml"; + @Rule + public TemporaryFolder tf = new TemporaryFolder(); + + @Test + public void ruleFilterTest() { + File outputFolder = tf.newFolder("ruleFilterTest"); + try { + File file = Resources.extractResource(FILE_RULE_FILTER, outputFolder); + final RuleFilterManager filterManager = new RuleFilterManager(file); + filterManager.printRuleFilter(); + HashMap selectedOptions = new HashMap(); + selectedOptions.put(MaldiOrEsiCondition.getID(), MaldiOrEsiCondition.ESI.getOption()); + filterManager.getCVMappingRulesToSkipByUserOptions(selectedOptions); + } catch (JAXBException e) { + e.printStackTrace(); + fail(); + } + } + + @Test + public void ruleFilterTest2() { + File outputFolder = tf.newFolder("ruleFilterTest2"); + try { + System.out.println("\n\n---------------------"); + File file = Resources.extractResource(FILE_RULE_FILTER, outputFolder); + final RuleFilterManager filterManager = new RuleFilterManager(file); + HashMap selectedOptions = new HashMap(); + selectedOptions.put(MaldiOrEsiCondition.getID(), MaldiOrEsiCondition.ESI.getOption()); + final Set cvMappingRulesToExclude = filterManager + .getCVMappingRulesToSkipByUserOptions(selectedOptions); + for (String ruleId : cvMappingRulesToExclude) { + System.out.println(ruleId); + } + } catch (JAXBException e) { + e.printStackTrace(); + fail(); + } + } +}