Buggy code:
JSONObject s = new JSONObject ( ) ; s . put ( id , new JSONString ( ( ( MMpQualifier ) ( rel . getObject ( ) ) ) . getQualifier ( ) . getSource ( ) . getUrl ( ) ) ) ; s . put ( rdfLabel , new JSONString ( ( ( MMpQualifier ) ( rel . getObject ( ) ) ) . getQualifier ( ) . getSource ( ) . getLabel ( ) ) ) ; q . put ( source , s ) ; qualifiedBy . set ( ( counter ++ ) , q ) ; } } discourseElement . put ( mpQualifiedBy , qualifiedBy ) ; } JSONArray asserts = new JSONArray ( ) ; asserts . set ( asserts . size ( ) , discourseElement ) ; if ( ! ( annotation . getMicroPublication ( ) . getEvidence ( ) . isEmpty ( ) ) ) { JSONArray supportedBy = new JSONArray ( ) ; JSONArray challengedBy = new JSONArray ( ) ; for ( MMpRelationship rel : annotation . getMicroPublication ( ) . getEvidence ( ) ) { if ( rel . getName ( ) . equals ( mpSupportedBy ) ) { if ( ( rel . getObjectElement ( ) ) instanceof MMpReference ) { MMpReference mMpReference = ( ( MMpReference ) ( rel . getObjectElement ( ) ) ) ; JSONObject reference = new JSONObject ( ) ; if ( ! ( mMpReference . getReference ( ) . getPubMedId ( ) . isEmpty ( ) ) ) { reference . put ( id , new JSONString ( ( "urn:pubmed:" + ( mMpReference . getReference ( ) . getPubMedId ( ) ) ) ) ) ; } reference . put ( type , new JSONString ( IMicroPublicationsOntology . mpReference ) ) ; reference . put ( mpCitation , new JSONString ( PubMedCitationPainter . getFullCitationPlainString ( mMpReference . getReference ( ) , manager . _domeo ) ) ) ; manager . serializeExpression ( reference , new JSONString ( ( ( "urn:pubmed:" + ( mMpReference . getReference ( ) . getPubMedId ( ) ) ) + ":expr" ) ) , mMpReference . getReference ( ) ) ; supportedBy . set ( supportedBy . size ( ) , reference ) ; asserts . set ( asserts . size ( ) , reference ) ; } else if ( ( rel . getObjectElement ( ) ) instanceof MMpDataImage ) { MMpDataImage mMpDataImage = ( ( MMpDataImage ) ( rel . getObjectElement ( ) ) ) ; manager . _domeo . getLogger ( ) . info ( this , ( "Serializing<seq2seq4repair_space>Image<seq2seq4repair_space>Data<seq2seq4repair_space>" + ( mMpDataImage . getId ( ) ) ) ) ; JSONObject imageData = new JSONObject ( ) ; imageData . put ( generalId , new JSONString ( mMpDataImage . getId ( ) ) ) ; imageData . put ( generalType , new JSONString ( IMicroPublicationsOntology . mpDataImage ) ) ; imageData . put ( rdfValue , new JSONString ( mMpDataImage . getSelector ( ) . getTarget ( ) . getUrl ( ) ) ) ; JSONValue v = manager . serialize ( mMpDataImage . getSelector ( ) ) ; imageData . put ( HAS_TARGET , v ) ; supportedBy . set ( challengedBy . size ( ) , imageData ) ; asserts . set ( asserts . size ( ) , imageData ) ; } } else if ( rel . getName ( ) . equals ( mpChallengedBy ) ) { if ( ( rel . getObjectElement ( ) ) instanceof MMpReference ) { MMpReference mMpReference = ( ( MMpReference ) ( rel . getObjectElement ( ) ) ) ; JSONObject reference = new JSONObject ( ) ; if ( ! ( mMpReference . getReference ( ) . getPubMedId ( ) . isEmpty ( ) ) ) { reference . put ( id , new JSONString ( ( "urn:pubmed:" + ( mMpReference . getReference ( ) . getPubMedId ( ) ) ) ) ) ; } reference . put ( type , new JSONString ( IMicroPublicationsOntology . mpReference ) ) ; reference . put ( mpCitation , new JSONString ( PubMedCitationPainter . getFullCitationPlainString ( mMpReference . getReference ( ) , manager . _domeo ) ) ) ; manager . serializeExpression ( reference , new JSONString ( ( ( "urn:pubmed:" + ( mMpReference . getReference ( ) . getPubMedId ( ) ) ) + ":expr" ) ) , mMpReference . getReference ( ) ) ; challengedBy . set ( challengedBy . size ( ) , reference ) ; asserts . set ( asserts . size ( ) , reference ) ; } else if ( ( rel . getObjectElement ( ) ) instanceof MMpDataImage ) { MMpDataImage mMpDataImage = ( ( MMpDataImage ) ( rel . getObjectElement ( ) ) ) ; JSONObject imageData = new JSONObject ( ) ; imageData . put ( generalId , new JSONString ( mMpDataImage . getId ( ) ) ) ; imageData . put ( generalType , new JSONString ( "mp:DataImage" ) ) ; JSONValue v = manager . serialize ( mMpDataImage . getSelector ( ) ) ; imageData . put ( HAS_TARGET , v ) ; challengedBy . set ( challengedBy . size ( ) , imageData ) ; asserts . set ( asserts . size ( ) , imageData ) ; } } } if ( ( supportedBy . size ( ) ) > 0 ) { discourseElement . put ( mpSupportedBy , supportedBy ) ; } if ( ( challengedBy . size ( ) ) > 0 ) { <START_BUG> discourseElement . put ( mpChallengedBy , supportedBy ) ; <END_BUG> } } body . put ( mpArgues , new JSONString ( annotation . getMicroPublication ( ) . getArgues ( ) . getId ( ) ) ) ; body . put ( mpAsserts , asserts ) ; return body ; } }

Fix:
discourseElement . put ( mpChallengedBy , challengedBy ) ;