private String cleanAndTrim(String valueToClean, Class clazz, String propertyName) { String returnString = StringHelper.cleanUpWhiteSpace(valueToClean); ATFieldInfo fieldInfo = ATFieldInfo.getFieldInfo(clazz, propertyName); if (fieldInfo.getStringLengthLimit() != null && fieldInfo.getStringLengthLimit() > 0) { return StringHelper.trimToLength(returnString, fieldInfo.getStringLengthLimit()); } else { return returnString; } }
public static String getLabel(Did did) { String returnString = "Unknown component"; for (Object o : did.getMDid()) { if (o instanceof Unittitle) { return StringHelper.cleanUpWhiteSpace(EADHelper.ObjectNodetoString(o)); } } return returnString; }
private void parseAccessionNumber(Accessions accession, IdentifierType value) { String composite = value.getComposite(); if (composite != null) { StringTokenizer st = new StringTokenizer(composite, "./-"); int count = 0; String thisToken; while (st.hasMoreTokens()) { count++; thisToken = StringHelper.cleanUpWhiteSpace((String) st.nextElement()); if (count == 1) { accession.setAccessionNumber1( StringHelper.trimToLength( thisToken, ATFieldInfo.checkFieldLength( Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_1))); } else if (count == 2) { accession.setAccessionNumber2( StringHelper.trimToLength( thisToken, ATFieldInfo.checkFieldLength( Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_2))); } else if (count == 3) { accession.setAccessionNumber3( StringHelper.trimToLength( thisToken, ATFieldInfo.checkFieldLength( Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_3))); } else if (count == 4) { accession.setAccessionNumber4( StringHelper.trimToLength( thisToken, ATFieldInfo.checkFieldLength( Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_4))); } } } else { accession.setAccessionNumber1( cleanAndTrim( value.getPart1(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_1)); if (value.getPart2() != null) { accession.setAccessionNumber2( cleanAndTrim( value.getPart2(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_2)); } if (value.getPart3() != null) { accession.setAccessionNumber3( cleanAndTrim( value.getPart3(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_3)); } if (value.getPart4() != null) { accession.setAccessionNumber4( cleanAndTrim( value.getPart4(), Accessions.class, Accessions.PROPERTYNAME_ACCESSION_NUMBER_4)); } } }