Skip to content

Commit

Permalink
Merge pull request #349 from ncats/ep_validation_msg_fix
Browse files Browse the repository at this point in the history
Normalize the ValidationMassages texts
  • Loading branch information
blueSwordfish authored Jul 9, 2024
2 parents 8c59bfc + b2374e6 commit 8a8041a
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
if(!allCurrentBdNums.contains(bd)){
if(! ("SUPERSEDED".equalsIgnoreCase(bdnumType) || "SUPERCEDED".equalsIgnoreCase(bdnumType))){
//1. If the BDNUM literal that existed in the old record (e.g. XXXXXX) no longer exists in the current record, throw an error unless that BDNUM was marked as type "superseded".
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE(bdnumType + " BDNUM " + bd + " has been removed, but only SUPERSEDED BDNUM codes may be removed"));
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("%s BDNUM %s has been removed, but only SUPERSEDED BDNUM codes may be removed", bdnumType, bd));

}else {
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE(bdnumType + " BDNUM " + bd + " has been removed"));
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("%s BDNUM %s has been removed", bdnumType, bd));
}
}
}
Expand All @@ -75,7 +75,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
//or if it has been removed (in which case we alrady added an error above for that)
if(primaries !=null && primaries.size() > 1){
//2. If there are 2 or more BDNUMs where both are type "PRIMARY", throw an error.
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("can not have more than 1 PRIMARY BDNUM but have : " + primaries));
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Cannot have more than 1 PRIMARY BDNUM but have : %s", primaries));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,15 @@ public Chemical toChemical(List<GinasProcessingMessage> messages, boolean comput
}
}catch(Exception e){
e.printStackTrace();
messages.add(GinasProcessingMessage.ERROR_MESSAGE(e.getMessage()));
messages.add(GinasProcessingMessage.ERROR_MESSAGE("SMILES parsing error: %s", e.getMessage()));
}

}else{
try {
c = Chemical.parseMol(molfile);
}catch(Exception e){
e.printStackTrace();
messages.add(GinasProcessingMessage.ERROR_MESSAGE(e.getMessage()));
messages.add(GinasProcessingMessage.ERROR_MESSAGE("Molfile parsing error: %s", e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void checkValance(Structure newstr, List<GinasProcessingMessage> g
for (Atom atom : c.getAtoms()) {
if (atom.hasValenceError()) {
GinasProcessingMessage mes = GinasProcessingMessage
.WARNING_MESSAGE("Valence Error on " + atom.getSymbol() + " atom (" + (atom.getAtomIndexInParent() + 1) + ") ");
.WARNING_MESSAGE("Valence Error on %s atom (%s)", atom.getSymbol(), (atom.getAtomIndexInParent() + 1));
gpm.add(mes);
}
}
Expand All @@ -73,7 +73,7 @@ public static void checkValance(Structure newstr, List<GinasProcessingMessage> g
public static void checkChargeBalance(Structure newstr, List<GinasProcessingMessage> gpm) {
if (newstr.charge != 0) {
GinasProcessingMessage mes = GinasProcessingMessage
.WARNING_MESSAGE("Structure is not charge-balanced, net charge of: " + newstr.charge);
.WARNING_MESSAGE("Structure is not charge-balanced, net charge of: %s", newstr.charge);
gpm.add(mes);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ else if ("count".equals(property)) {
}

if (!parsed) {
messages.add(GinasProcessingMessage.WARNING_MESSAGE("Unknown property \""
+property+"\" while parsing "
+bean+"; skipping it.."));

messages.add(GinasProcessingMessage.WARNING_MESSAGE("Unknown property \"%s\" while parsing %s; skipping it..", property, bean));
log.debug("Unknown property \""
+property+"\" while parsing "
+bean+"; skipping it..");
Expand All @@ -74,7 +71,7 @@ else if ("count".equals(property)) {
}
}
catch (Exception ex) {
messages.add(GinasProcessingMessage.ERROR_MESSAGE("Error parsing substance JSON:" + ex.getMessage()));
messages.add(GinasProcessingMessage.ERROR_MESSAGE("Error parsing substance JSON:%s", ex.getMessage()));
ex.printStackTrace();
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,8 @@ public static MolecularWeightAndFormulaContribution generateProteinWeightAndForm
//There is no computable fragment to use
log.info("No usable molecular weight contribution from structural modification fragment: " + mod.molecularFragment.refuuid);
messages.add(
GinasProcessingMessage.WARNING_MESSAGE(
String.format("Structural modification will not affect the molecular weight because %s has no associated molecular weight",
mod.molecularFragment.refPname)));
GinasProcessingMessage.WARNING_MESSAGE("Structural modification will not affect the molecular weight because %s has no associated molecular weight",
mod.molecularFragment.refPname));
}
else if (contribution.getMw() > 0 || (contribution.getMwHigh() > 0 && contribution.getMwLow() > 0)) {
//removeWater(contribution.getFormulaMap()); 1 December 2020 MAM no need for this
Expand Down Expand Up @@ -405,9 +404,8 @@ else if (contribution.getMw() > 0 || (contribution.getMwHigh() > 0 && contributi
}
else {
log.trace("extent other than complete: " + mod.extent);
messages.add(GinasProcessingMessage.WARNING_MESSAGE(
String.format("Note: structural modification with extent '%s' will not be counted toward the molecular weight",
mod.extent != null ? mod.extent : "[missing]")));
messages.add(GinasProcessingMessage.WARNING_MESSAGE("Note: structural modification with extent '%s' will not be counted toward the molecular weight",
mod.extent != null ? mod.extent : "[missing]"));
}
}
}
Expand Down Expand Up @@ -680,15 +678,14 @@ private static MolecularWeightAndFormulaContribution getContributionForID(Substa
log.trace("contribution: " + ((contribution == null) ? "null" : "not null"));
if ((mwHigh != null && mwHigh > 0) || (mwHighLimit != null && mwHighLimit > 0)
|| (mwLow != null && mwLow > 0) || (mwLowLimit != null && mwLowLimit > 0)) {
contribution.getMessages().add(GinasProcessingMessage.WARNING_MESSAGE(
String.format("Using range of molecular weights for substance %s in structural modification",
referencedSubstance.getName())));
contribution.getMessages().add(GinasProcessingMessage.WARNING_MESSAGE("Using range of molecular weights for substance %s in structural modification",
referencedSubstance.getName()));
}
}
else {
GinasProcessingMessage warning = GinasProcessingMessage.WARNING_MESSAGE(
String.format("Structural modification molecular fragment %s has no average molecular weight and will not be used in the molecular weight calculation",
referencedSubstance.getApprovalIDDisplay()));
"Structural modification molecular fragment %s has no average molecular weight and will not be used in the molecular weight calculation",
referencedSubstance.getApprovalIDDisplay());
contribution = new MolecularWeightAndFormulaContribution(referencedSubstance.substanceClass.name(), warning);
}
log.trace("containsStarAtom: " + containsStarAtom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static boolean validateReference(Substance s,
Reference dbReference = referenceRepository.getOne(UUID.fromString(ref.getValue()));
if(dbReference !=null) {
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE(
"Reference type: \"%s\" citation: \"%s\" uuid \"%s\" not found on substance.",
"Reference type: \"%s\" citation: \"%s\" uuid \"%s\" not found on substance.",
dbReference.docType, dbReference.citation, ref.getValue()));
}else{
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Reference \"%s\" not found on substance.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
//not a mol convert it
//struc is already standardized
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE(
"structure should always be specified as mol file converting to format to mol automatically").appliableChange(true),
"Structure should always be specified as mol file converting to format to mol automatically").appliableChange(true),
() -> {
try {
cs.setStructure(cs.getStructure().copy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void validate(Substance s, Substance oldSubstance, ValidatorCallback call
}
}
} catch (IOException e) {
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("could not validate CV"));
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Could not validate CV"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ private GinasProcessingMessage createDiffMessage(List<DefinitionalElements.Defin
}
}
if(messageParts.size() == 1) {
return GinasProcessingMessage.WARNING_MESSAGE("A definitional change has been made: %s please reaffirm. ",
return GinasProcessingMessage.WARNING_MESSAGE("A definitional change has been made: %s please reaffirm.",
messageParts.get(0));
}
return GinasProcessingMessage.WARNING_MESSAGE("Definitional changes have been made: %s; please reaffirm. ",
return GinasProcessingMessage.WARNING_MESSAGE("Definitional changes have been made: %s; please reaffirm.",
String.join("; ", messageParts));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)

}
if (n.getName() == null) {
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("name can not be null"));
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Name can not be null"));
continue;
}
if (n.preferred) {
Expand Down Expand Up @@ -188,7 +188,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
if (name != null && r.matches(name)) {
GinasProcessingMessage mes = GinasProcessingMessage
.WARNING_MESSAGE(
r.getMessage(name))
r.getMessage("%s"), name)
.appliableChange(true);
callback.addMessage(mes, () -> n.setName(r.fix(name)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
//for now just null/blank need to confer with stakeholders if validation is needed or not
if(su.sequence == null || su.sequence.trim().isEmpty()){
if(Substance.SubstanceDefinitionLevel.INCOMPLETE.equals(cs.definitionLevel)){
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("subunit at position %s is blank. This is allowed but discouraged for incomplete nucleic acid records.", (i +1)));
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Subunit at position %s is blank. This is allowed but discouraged for incomplete nucleic acid records.", (i +1)));
}else {
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("subunit at position %s is blank", (i +1)));
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Subunit at position %s is blank", (i +1)));
}
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ private void validateSequence(NucleicAcidSubstance s, ValidatorCallback callback
}catch(Exception e){
//invalid bases
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE(
"invalid nucleic acid sequence base in subunit %s %s", subunit.subunitIndex, e.getMessage()));
"Invalid nucleic acid sequence base in subunit %s %s", subunit.subunitIndex, e.getMessage()));

}
}
Expand Down Expand Up @@ -351,7 +351,7 @@ private void validateSequenceDuplicates(
} catch (Exception e) {
log.error("Problem executing duplicate search function", e);
callback.addMessage(GinasProcessingMessage
.ERROR_MESSAGE("Error performing seqeunce search on Nucleic Acid:",
.ERROR_MESSAGE("Error performing seqeunce search on Nucleic Acid:%s",
e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
if (mentioned != null) {
if (!contained.containsAll(mentioned)) {
callback.addMessage(GinasProcessingMessage
.ERROR_MESSAGE("Mentioned attachment points '%s' in unit '%s' are not all found in actual connecitons '%s'. ",
.ERROR_MESSAGE("Mentioned attachment points '%s' in unit '%s' are not all found in actual connecitons '%s'.",
mentioned.toString(), u.label, contained.toString()));
}
}
Expand All @@ -121,7 +121,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
Set<String> leftovers = new HashSet<String>(rgroupMentions);
leftovers.removeAll(rgroupsWithMappings);
callback.addMessage(GinasProcessingMessage
.ERROR_MESSAGE("Mentioned attachment point(s) '%s' cannot be found ",
.ERROR_MESSAGE("Mentioned attachment point(s) '%s' cannot be found",
leftovers.toString()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void validate(Substance s, Substance objold, ValidatorCallback callback)
Substance subAlternative = substanceRepository.findBySubstanceReference(relsub);
if(subAlternative ==null){
//does not exist
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("alternative definition not found %s", relsub.refPname));
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Alternative definition not found %s", relsub.refPname));
}else if (subAlternative.isPrimaryDefinition()) {
callback.addMessage(GinasProcessingMessage
.ERROR_MESSAGE("Primary definitions cannot be alternative definitions for other Primary definitions"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public void validate(Substance objnew, Substance objold, ValidatorCallback callb
//for now just null/blank need to confer with stakeholders if amino acid validation is needed or not
if (su.sequence == null || su.sequence.trim().isEmpty()) {
if (Substance.SubstanceDefinitionLevel.INCOMPLETE.equals(cs.definitionLevel)) {
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("subunit at position %s is blank. This is allowed but discouraged for incomplete protein records.", (i + 1)));
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Subunit at position %s is blank. This is allowed but discouraged for incomplete protein records.", (i + 1)));
}
else {
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("subunit at position %s is blank", (i + 1)));
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Subunit at position %s is blank", (i + 1)));
}
}
}
Expand Down Expand Up @@ -398,8 +398,8 @@ private void validateSequenceDuplicates(
} catch (Exception e) {
log.error("Problem executing duplicate search function", e);
callback.addMessage(GinasProcessingMessage
.ERROR_MESSAGE("Error performing seqeunce search on protein:"
+ e.getMessage()));
.ERROR_MESSAGE("Error performing seqeunce search on protein:%s",
e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ public void validateFull(Substance objnew, Substance objold, ValidatorCallback c
if (!stdNameStandardizer.isStandardized(name.stdName)) {
warnedAboutThisNameStandardization =true;
if( invalidStdNameBehavior== InvalidStdNameBehavior.error) {
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Standardized name does not meet standards. This name may contain one or more non-allowed character: '%s'",
callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Standardized name does not meet standards. This name may contain one or more non-allowed character: '%s'",
name.stdName));
}else {
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Standardized name does not meet standards. This name may contain one or more non-allowed character: '%s'",
callback.addMessage(GinasProcessingMessage.WARNING_MESSAGE("Standardized name does not meet standards. This name may contain one or more non-allowed character: '%s'",
name.stdName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void validate(Substance testSubstance, Substance oldSubstance, ValidatorC
if (fullMatches.size() > 0) {
for (int i = 0; i < fullMatches.size(); i++) {
Substance possibleMatch = fullMatches.get(i);
GinasProcessingMessage mes = GinasProcessingMessage.ERROR_MESSAGE("Substance %s (ID: %s) appears to be a full duplicate\n",
GinasProcessingMessage mes = GinasProcessingMessage.ERROR_MESSAGE("Substance %s (ID: %s) appears to be a full duplicate",
possibleMatch.getName(), possibleMatch.uuid);
mes.addLink(ValidationUtils.createSubstanceLink(possibleMatch.asSubstanceReference()));
//.createSubstanceLink((possibleMatch));
Expand All @@ -73,7 +73,7 @@ public void validate(Substance testSubstance, Substance oldSubstance, ValidatorC
for (int i = 0; i < matches.size(); i++) {
Substance possibleMatch = matches.get(i);
log.debug("in SubstanceUniquenessValidator before message creation");
GinasProcessingMessage mes = GinasProcessingMessage.WARNING_MESSAGE("Substance %s (ID: %s) is a possible duplicate\n",
GinasProcessingMessage mes = GinasProcessingMessage.WARNING_MESSAGE("Substance %s (ID: %s) is a possible duplicate",
possibleMatch.getName(), possibleMatch.uuid);
log.debug("in SubstanceUniquenessValidator, created warning with message " + mes.getMessage());
mes.addLink(ValidationUtils.createSubstanceLink(possibleMatch.asSubstanceReference()));
Expand Down

0 comments on commit 8a8041a

Please sign in to comment.