private static synchronized void initPluginNames() { if (pluginNames == null) { try { if (dci == null) { dci = new DCInputsReader(); } } catch (DCInputsReaderException e) { log.error("Failed reading DCInputs initialization: ", e); } List<String> names = new ArrayList<String>(); Iterator pi = dci.getPairsNameIterator(); while (pi.hasNext()) { names.add((String) pi.next()); } pluginNames = names.toArray(new String[names.size()]); log.debug("Got plugin names = " + Arrays.deepToString(pluginNames)); } }
public DCInputsReader(String fileName) throws DCInputsReaderException { buildInputs(fileName); }
private void buildInputs(String fileName) throws DCInputsReaderException { formDefns = new HashMap<String, List<List<Map<String, String>>>>(); valuePairs = new HashMap<String, List<String>>(); String uri = "file:" + new File(fileName).getAbsolutePath(); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); DocumentBuilder db = factory.newDocumentBuilder(); Document doc = db.parse(uri); doNodes(doc); checkValues(); } catch (FactoryConfigurationError fe) { throw new DCInputsReaderException("Cannot create Submission form parser", fe); } catch (Exception e) { throw new DCInputsReaderException("Error creating submission forms: " + e); } }
return; Node e = getElement(n); NodeList nl = e.getChildNodes(); int len = nl.getLength(); for (int i = 0; i < len; i++) { Node nd = nl.item(i); if ((nd == null) || isEmptyTextNode(nd)) { continue; processDefinition(nd); foundDefs = true; } else if (tagName.equals("form-value-pairs")) { processValuePairs(nd);
DCInputsReader inputsReader = new DCInputsReader(); request.setAttribute("submission.inputs", inputsReader.getInputs(c .getHandle()));
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); } }
private void autoRegisterAuthorityFromInputReader() { try { DCInputsReader dcInputsReader = new DCInputsReader(); for (DCInputSet dcinputSet : dcInputsReader.getAllInputs(Integer.MAX_VALUE, 0)) { DCInput[][] dcinputs = dcinputSet.getFields(); for (DCInput[] dcrows : dcinputs) { for (DCInput dcinput : dcrows) { if (StringUtils.isNotBlank(dcinput.getPairsType()) || StringUtils.isNotBlank(dcinput.getVocabulary())) { String authorityName = dcinput.getPairsType(); if (StringUtils.isBlank(authorityName)) { authorityName = dcinput.getVocabulary(); } if (!StringUtils.equals(dcinput.getInputType(), "qualdrop_value")) { String fieldKey = makeFieldKey(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier()); boolean req = ConfigurationManager .getBooleanProperty("authority.required." + fieldKey, false); controlled.put(fieldKey, true); isAuthorityRequired.put(fieldKey, req); } } } } } } catch (DCInputsReaderException e) { throw new IllegalStateException(e.getMessage(), e); } } }
/** * Ensure that the inputs reader has been initialized, this method may be * called multiple times with no ill-effect. */ private static void initializeInputsReader() throws DCInputsReaderException { if (INPUTS_READER == null) { INPUTS_READER = new DCInputsReader(); } }
protected DCInput getDCInput(String formName, String schema, String element, String qualifier) throws DCInputsReaderException { List<DCInputSet> dcinputsets = new DCInputsReader().getInputsBySubmissionName(formName); for (DCInputSet dcinputset : dcinputsets) { for (DCInput[] dcrow : dcinputset.getFields()) { for (DCInput dcinput : dcrow) { if (dcinput.getSchema().equals(schema) && dcinput.getElement().equals(element) && ((dcinput.getQualifier() != null && dcinput .getQualifier().equals(qualifier)) || (dcinput.getQualifier() == null && qualifier == null))) { return dcinput; } } } } return null; }
for (int i = 0; i < len; i++) { Node nd = nl.item(i); if (!isEmptyTextNode(nd)) { String tagName = nd.getNodeName(); String value = getValue(nd); field.put(tagName, value); if (tagName.equals("input-type")) { || value.equals("qualdrop_value") || value.equals("list")) { String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME); if (pairTypeName == null) { throw new SAXException("Form " + formName + ", field " + String closedVocabularyString = getAttribute(nd, "closed"); field.put("closedVocabulary", closedVocabularyString); } else if (tagName.equals("language")) { if (Boolean.valueOf(value)) { String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME); if (pairTypeName == null) { throw new SAXException("Form " + formName + ", field " +
request.setAttribute("submission.inputs", DescribeStep.getInputsReader(formFileName).getInputs(c .getHandle()));
String pairsName = getAttribute(nd, PAIR_TYPE_NAME); String dcTerm = getAttribute(nd, "dc-term"); if (pairsName == null) { String errString = String vName = vn.getNodeName(); if (vName.equals("displayed-value")) { display = getValue(vn); } else if (vName.equals("stored-value")) { storage = getValue(vn); if (storage == null) { storage = "";
String formName = getAttribute(nd, "name"); if (formName == null) { throw new SAXException("form element has no name attribute"); processRow(formName, j, npg, fields); rows.add(fields);
@Override public Choices getBestMatch(String field, String text, Collection collection, String locale) { String formName; try { init(); if (collection == null) { Set<Choice> choices = new HashSet<Choice>(); //workaround search in all authority configured for (ChoiceAuthority ca : delegates.values()) { Choices tmp = ca.getBestMatch(field, text, null, locale); if (tmp.total > 0) { Set<Choice> mySet = new HashSet<Choice>(Arrays.asList(tmp.values)); choices.addAll(mySet); } } if (!choices.isEmpty()) { Choice[] results = new Choice[choices.size() - 1]; choices.toArray(results); return new Choices(results, 0, choices.size(), Choices.CF_UNCERTAIN, false); } } else { formName = dci.getInputFormNameByCollectionAndField(collection, field); return delegates.get(formName).getBestMatch(field, text, collection, locale); } } catch (DCInputsReaderException e) { log.error(e.getMessage(), e); } return new Choices(Choices.CF_NOTFOUND); }
try DCInputsReader inputsReader = new DCInputsReader(); request.setAttribute("submission.inputs", inputsReader.getInputs(c .getHandle()));
DCInputsReader inputsReader = new DCInputsReader(formFileName); List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);
private void autoRegisterChoiceAuthorityFromInputReader() { try { DCInputsReader dcInputsReader = new DCInputsReader(); for (DCInputSet dcinputSet : dcInputsReader.getAllInputs(Integer.MAX_VALUE, 0)) { DCInput[][] dcinputs = dcinputSet.getFields(); for (DCInput[] dcrows : dcinputs) {
private void init() { try { if (dci == null) { dci = new DCInputsReader(); } } catch (DCInputsReaderException e) { log.error("Failed reading DCInputs initialization: ", e); } }
try inputSet = getInputsReader().getInputs(submission.getCollection().getHandle()); inputs = inputSet.getPageRows(getPage()-1, submission.hasMultipleTitles(), submission.isPublishedBefore());
@Override public Choices getMatches(String field, String query, Collection collection, int start, int limit, String locale) { String formName; try { init(); if (collection == null) { Set<Choice> choices = new HashSet<Choice>(); //workaround search in all authority configured for (ChoiceAuthority ca : delegates.values()) { Choices tmp = ca.getMatches(field, query, null, start, limit, locale); if (tmp.total > 0) { Set<Choice> mySet = new HashSet<Choice>(Arrays.asList(tmp.values)); choices.addAll(mySet); } } if (!choices.isEmpty()) { Choice[] results = new Choice[choices.size() - 1]; choices.toArray(results); return new Choices(results, 0, choices.size(), Choices.CF_AMBIGUOUS, false); } } else { formName = dci.getInputFormNameByCollectionAndField(collection, field); return delegates.get(formName).getMatches(field, query, collection, start, limit, locale); } } catch (DCInputsReaderException e) { log.error(e.getMessage(), e); } return new Choices(Choices.CF_NOTFOUND); }