/** * Check the type of a confidence * @param conf * @param typeId * @param typeName * @return */ public static boolean doesConfidenceHaveType(Confidence conf, String typeId, String typeName){ if (conf == null || (typeName == null && typeId == null)){ return false; } CvTerm type = conf.getType(); // we can compare identifiers if (typeId != null && type.getMIIdentifier() != null){ // we have the same topic id return type.getMIIdentifier().equals(typeId); } // we need to compare topic names else if (typeName != null) { return typeName.equalsIgnoreCase(type.getShortName()); } return false; }
/** * Use DefaultConfidenceComparator to know if two confidences are equals. * @param confidence1 * @param confidence2 * @return true if the two confidences are equal */ public static boolean areEquals(Confidence confidence1, Confidence confidence2){ if (confidence1 == confidence2){ return true; } else if (confidence1 == null || confidence2 == null){ return false; } else { CvTerm type1 = confidence1.getType(); CvTerm type2 = confidence2.getType(); if (!DefaultCvTermComparator.areEquals(type1, type2)){ return false; } String value1 = confidence1.getValue(); String value2 = confidence2.getValue(); return value1.equals(value2); } } }
public void writeConfidence(Confidence conf) throws IOException { if (conf != null){ // write confidence type first if (conf.getType().getFullName() != null){ escapeAndWriteString(conf.getType().getFullName()); } else{ escapeAndWriteString(conf.getType().getShortName()); } // write confidence value writer.write(MitabUtils.XREF_SEPARATOR); escapeAndWriteString(conf.getValue()); } }
/** * * @param conf * @return the hashcode consistent with the equals method for this comparator */ public static int hashCode(Confidence conf){ if (unambiguousConfidenceComparator == null){ unambiguousConfidenceComparator = new UnambiguousConfidenceComparator(); } if (conf == null){ return 0; } int hashcode = 31; CvTerm type = conf.getType(); hashcode = 31*hashcode + UnambiguousCvTermComparator.hashCode(type); String value = conf.getValue(); hashcode = 31*hashcode + value.hashCode(); return hashcode; } }
@Override public void writeConfidence(Confidence conf) throws IOException { if (conf != null){ // write confidence type first if (conf.getType().getFullName() != null){ escapeAndWriteString(conf.getType().getFullName()); } else{ escapeAndWriteString(conf.getType().getShortName()); } // write confidence value getWriter().write(MitabUtils.XREF_SEPARATOR); escapeAndWriteString(conf.getValue()); // write text if (conf instanceof MitabConfidence){ MitabConfidence mitabConf = (MitabConfidence) conf; if (mitabConf.getText() != null){ getWriter().write("("); getWriter().write(mitabConf.getText()); getWriter().write(")"); } } } }
@Override public void writeConfidence(Confidence conf) throws IOException { if (conf != null){ // write confidence type first if (conf.getType().getFullName() != null){ escapeAndWriteString(conf.getType().getFullName()); } else{ escapeAndWriteString(conf.getType().getShortName()); } // write confidence value getWriter().write(MitabUtils.XREF_SEPARATOR); escapeAndWriteString(conf.getValue()); // write text if (conf instanceof MitabConfidence){ MitabConfidence mitabConf = (MitabConfidence) conf; if (mitabConf.getText() != null){ getWriter().write("("); getWriter().write(mitabConf.getText()); getWriter().write(")"); } } } }
public void write(Confidence object) throws IOException { MIJsonUtils.writeStartObject(writer); MIJsonUtils.writeProperty("type", JSONValue.escape(object.getType().getShortName()), writer); MIJsonUtils.writeSeparator(writer); MIJsonUtils.writeProperty("value", JSONValue.escape(object.getValue()), writer); MIJsonUtils.writeEndObject(writer); } }
final OntologyAccess access = ontologyManager.getOntologyAccess("MI"); CvTerm type = confidence.getType(); if (confidence.getValue() == null || confidence.getValue().trim().length() == 0 || PsiXmlUtils.UNSPECIFIED.equals(confidence.getValue()) || MitabUtils.UNKNOWN_ID.equals(confidence.getValue())){ MiContext xrefContext = RuleUtils.buildContext(confidence, "confidence"); if (messages.isEmpty()){