/** * Does the current input set define the named field? * Scan through every field in every page of the input set * * @param fieldName selects the field. * @return true if the current set has the named field */ public boolean isFieldPresent(String fieldName) { for (int i = 0; i < inputs.length; i++) { for (int j = 0; j < inputs[i].length; j++) { DCInput field = inputs[i][j]; String fullName = field.getFieldName(); if (fullName.equals(fieldName)) { return true; } } } return false; }
protected boolean doField(DCInput dcf, boolean addTitleAlternative, boolean addPublishedBefore) { String rowName = dcf.getFieldName(); if (rowName.equals("dc.title.alternative") && !addTitleAlternative) { return false; } if (rowName.equals("dc.date.issued") && !addPublishedBefore) { return false; } if (rowName.equals("dc.publisher.null") && !addPublishedBefore) { return false; } if (rowName.equals("dc.identifier.citation") && !addPublishedBefore) { return false; } return true; }
/** * Does the current input set define the named field? * and is valid for the specified document type * Scan through every field in every page of the input set * * @param fieldName field name * @param documentType doc type * @return true if the current set has the named field */ public boolean isFieldPresent(String fieldName, String documentType) { if (documentType == null) { documentType = ""; } for (int i = 0; i < inputs.length; i++) { for (int j = 0; j < inputs[i].length; j++) { DCInput field = inputs[i][j]; String fullName = field.getFieldName(); if (fullName.equals(fieldName)) { if (field.isAllowedFor(documentType)) { return true; } } } } return false; }
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection) throws DCInputsReaderException { DCInputsReader reader = new DCInputsReader(); List<DCInputSet> from = reader.getInputsByCollectionHandle(fromCollection.getHandle()); List<DCInputSet> to = reader.getInputsByCollectionHandle(toCollection.getHandle()); Set<String> fromFieldName = new HashSet<>(); Set<String> toFieldName = new HashSet<>(); for (DCInputSet ff : from) { for (DCInput[] fdcrow : ff.getFields()) { for (DCInput fdc : fdcrow) { fromFieldName.add(fdc.getFieldName()); } } } for (DCInputSet tt : to) { for (DCInput[] tdcrow : tt.getFields()) { for (DCInput tdc : tdcrow) { toFieldName.add(tdc.getFieldName()); } } } return ListUtils.removeAll(fromFieldName, toFieldName); } }