protected List<String> getReqList(String handle) throws DCInputsReaderException { List<String> reqList = reqMap.get(handle); if (reqList == null) { reqList = reqMap.get("default"); } if (reqList == null) { reqList = new ArrayList<String>(); List<DCInputSet> inputSet = reader.getInputsByCollectionHandle(handle); for (DCInputSet inputs : inputSet) { for (DCInput[] row : inputs.getFields()) { for (DCInput input : row) { if (input.isRequired()) { StringBuilder sb = new StringBuilder(); sb.append(input.getSchema()).append("."); sb.append(input.getElement()).append("."); String qual = input.getQualifier(); if (qual == null) { qual = ""; } sb.append(qual); reqList.add(sb.toString()); } } } reqMap.put(inputs.getFormName(), reqList); } } return reqList; } }
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); } }
public String getInputFormNameByCollectionAndField(Collection collection, String field) throws DCInputsReaderException { List<DCInputSet> inputSets = getInputsByCollectionHandle(collection.getHandle()); for (DCInputSet inputSet : inputSets) { String[] tokenized = Utils.tokenize(field); String schema = tokenized[0]; String element = tokenized[1]; String qualifier = tokenized[2]; if (StringUtils.isBlank(qualifier)) { qualifier = null; } String standardized = Utils.standardize(schema, element, qualifier, "."); if (inputSet.isFieldPresent(standardized)) { return inputSet.getFormName(); } } throw new DCInputsReaderException("No field configuration found!"); }
List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);