From: <rv...@us...> - 2012-01-31 20:21:46
|
Revision: 1023 http://treebase.svn.sourceforge.net/treebase/?rev=1023&view=rev Author: rvos Date: 2012-01-31 20:21:36 +0000 (Tue, 31 Jan 2012) Log Message: ----------- Re-ordered state set generation so that "missing" is populated with all other states. Also, set the assignment of the XML id before any annotations are added, this so that the about attribute is updated correctly. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2012-01-31 19:53:12 UTC (rev 1022) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/nexus/nexml/NexmlMatrixWriter.java 2012-01-31 20:21:36 UTC (rev 1023) @@ -79,27 +79,23 @@ stateForSymbol.put(symbol, state); } } - UncertainCharacterState missing = xmlStateSet.createUncertainCharacterState("?", new HashSet<CharacterState>()); - UncertainCharacterState gap = xmlStateSet.createUncertainCharacterState("-", new HashSet<CharacterState>()); - missing.getStates().add(gap); - // then create the single state set out of the map, assigning all non-gap characters to missing + // then create the single state set out of the map, assigning all non-missing characters to missing + Set<CharacterState> xmlMissingStates = new HashSet<CharacterState>(); for ( Character symbol : stateForSymbol.keySet() ) { - CharacterState xmlState = null; - if ( symbol.charValue() == '?' ) { - xmlState = missing; + if ( symbol.charValue() != '?' && symbol.charValue() != '-' ) { + CharacterState xmlState = xmlStateSet.createCharacterState(symbol.toString()); + DiscreteCharState tbState = stateForSymbol.get(symbol); + xmlState.setLabel(tbState.getLabel()); + attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); + xmlMissingStates.add(xmlState); } - else if ( symbol.charValue() == '-' ) { - xmlState = gap; - } - else { - xmlState = xmlStateSet.createCharacterState(symbol.toString()); - missing.getStates().add(xmlState); - } - DiscreteCharState tbState = stateForSymbol.get(symbol); - xmlState.setLabel(tbState.getLabel()); - attachTreeBaseID((Annotatable)xmlState,tbState,DiscreteCharState.class); - } + } + UncertainCharacterState gap = xmlStateSet.createUncertainCharacterState("-", new HashSet<CharacterState>()); + xmlMissingStates.add(gap); + UncertainCharacterState missing = xmlStateSet.createUncertainCharacterState("?", xmlMissingStates); + missing.setLabel("?"); + gap.setLabel("-"); // then create the XML characters, assigning them all the same state set List<MatrixColumn> tbColumns = tbMatrix.getColumnsReadOnly(); @@ -120,16 +116,16 @@ } private void setMatrixAttributes(org.nexml.model.Matrix<?> xmlMatrix,CharacterMatrix tbMatrix) { - xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); - xmlMatrix.setBaseURI(mMatrixBaseURI); - xmlMatrix.setLabel(tbMatrix.getLabel()); - // attach matrix identifiers attachTreeBaseID((Annotatable)xmlMatrix, tbMatrix,Matrix.class); String tb1MatrixID = tbMatrix.getTB1MatrixID(); if ( null != tb1MatrixID ) { ((Annotatable)xmlMatrix).addAnnotationValue("tb:identifier.matrix.tb1", Constants.TBTermsURI, tb1MatrixID); } + + xmlMatrix.addAnnotationValue("skos:historyNote", Constants.SKOSURI, "Mapped from TreeBASE schema using "+this.toString()+" $Rev$"); + xmlMatrix.setBaseURI(mMatrixBaseURI); + xmlMatrix.setLabel(tbMatrix.getLabel()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |