// TODO: Check if this would be correct with multiple values and uris being passed back // First, need to order by uris in original and new values probably and // for literals, order by? Alphabetical or numeric value? Hard to say public static boolean hasFieldChanged( String fieldName, EditConfigurationVTwo editConfig, MultiValueEditSubmission submission) { List<String> orgValue = editConfig.getUrisInScope().get(fieldName); List<String> newValue = submission.getUrisFromForm().get(fieldName); // Sort both just in case if (orgValue != null) { Collections.sort(orgValue); } if (newValue != null) { Collections.sort(newValue); } if (orgValue != null && newValue != null) { if (orgValue.equals(newValue)) return false; else return true; } List<Literal> orgLit = editConfig.getLiteralsInScope().get(fieldName); List<Literal> newLit = submission.getLiteralsFromForm().get(fieldName); // TODO: Sort ? Need custom comparator // Collections.sort(orgLit); // Collections.sort(newLit); // for(Literal l: orgLit) // boolean fieldChanged = !EditLiteral.equalLiterals(orgLit, newLit); // TODO:Check if below acts as expected boolean fieldChanged = !orgLit.equals(newLit); if (!fieldChanged) { int orgLen = orgLit.size(); int newLen = newLit.size(); if (orgLen != newLen) { fieldChanged = true; } else { int i; for (i = 0; i < orgLen; i++) { if (!EditLiteral.equalLiterals(orgLit.get(i), newLit.get(i))) { fieldChanged = true; break; } } } } log.debug("field " + fieldName + " " + (fieldChanged ? "did Change" : "did NOT change")); return fieldChanged; }