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); } } }
/** * Alternate way of calling isRepeatable() * * @return the repeatable flag */ public boolean getRepeatable() { return isRepeatable(); }
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; } }
/** * Return the HTML / DRI field name for the given input. * * @param input * @return field name as a String (e.g. dc_contributor_editor) */ public static String getFieldName(DCInput input) { String dcSchema = input.getSchema(); String dcElement = input.getElement(); String dcQualifier = input.getQualifier(); if (dcQualifier != null && ! dcQualifier.equals(Item.ANY)) { return dcSchema + "_" + dcElement + '_' + dcQualifier; } else { return dcSchema + "_" + dcElement; } }
String fieldKey = MetadataAuthorityManager.makeFieldKey(dcInput.getSchema(), dcInput.getElement(), dcInput.getQualifier()); if (MetadataAuthorityManager.getManager().isAuthorityControlled(fieldKey)) select.setLabel(dcInput.getLabel()); select.setHelp(cleanHints(dcInput.getHints())); if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) select.addError(dcInput.getWarning()); if (dcInput.isRepeatable() || dcValues.length > 1)
select.setLabel(dcInput.getLabel()); select.setHelp(cleanHints(dcInput.getHints())); if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) select.addError(dcInput.getWarning()); if (dcInput.isRepeatable() || dcValues.length > 1) java.util.List<String> pairs = dcInput.getPairs(); for (int i = 0; i < pairs.size(); i += 2)
if (!input.isVisible(scope) && !input.isReadOnly(scope)) String inputType = input.getInputType(); String pairsName = input.getPairsType(); DCValue[] values; values = submission.getItem().getMetadata(input.getSchema(), input.getElement(), Item.ANY, Item.ANY); values = submission.getItem().getMetadata(input.getSchema(), input.getElement(), input.getQualifier(), Item.ANY); displayValue = input.getDisplayString(pairsName,value.value); String displayQual = input.getDisplayString(pairsName,qualifier); if (displayQual!=null && displayQual.length()>0) describeSection.addLabel(input.getLabel()); if (mam.isAuthorityControlled(value.schema, value.element, value.qualifier))
boolean readonly = dcInput.isReadOnly(scope); if (!dcInput.isVisible(scope) && !readonly) String schema = dcInput.getSchema(); String element = dcInput.getElement(); String qualifier = dcInput.getQualifier(); String inputType = dcInput.getInputType(); DCValue[] unfiltered = item.getMetadata(dcInput.getSchema(), dcInput.getElement(), Item.ANY, Item.ANY); ArrayList<DCValue> filtered = new ArrayList<DCValue>(); for (DCValue dcValue : unfiltered)
for (int j = 0; j < inputs[i].length; j++) { String inputField = Utils .standardize(inputs[i][j].getSchema(), inputs[i][j].getElement(), inputs[i][j].getQualifier(), "."); if (currentField.equals(inputField)) { myInputs = inputs[i][j]; String pairsName = myInputs.getPairsType(); String stored_value = value.getValue(); String displayVal = myInputs.getDisplayString(pairsName, stored_value);
public boolean isQualdropValue() { if ("qualdrop_value".equals(getInputType())) { return true; } return false; }
/** * Is this DCInput for display in readonly mode in the given scope? * If the scope differ from which in visibility field then we use the out attribute * of the visibility element. Possible values are: hidden (default) and readonly. * If the DCInput is visible in the scope then this methods must return false * * @param scope String identifying the scope that this input's readonly visibility * should be tested for * @return whether the input should be displayed in a readonly way or fully hidden */ public boolean isReadOnly(String scope) { if (isVisible(scope)) { return false; } else { return readOnly != null && readOnly.equalsIgnoreCase("readonly"); } }
/** * constructor * * @param formName form name * @param mandatoryFlags * @param rows the rows * @param listMap map */ public DCInputSet(String formName, List<List<Map<String, String>>> rows, Map<String, List<String>> listMap) { this.formName = formName; this.inputs = new DCInput[rows.size()][]; for (int i = 0; i < inputs.length; i++) { List<Map<String, String>> fields = rows.get(i); inputs[i] = new DCInput[fields.size()]; for (int j = 0; j < inputs[i].length; j++) { Map<String, String> field = rows.get(i).get(j); inputs[i][j] = new DCInput(field, listMap); } } }
textArea.setLabel(dcInput.getLabel()); textArea.setHelp(cleanHints(dcInput.getHints())); String fieldKey = MetadataAuthorityManager.makeFieldKey(dcInput.getSchema(), dcInput.getElement(), dcInput.getQualifier()); boolean isAuth = MetadataAuthorityManager.getManager().isAuthorityControlled(fieldKey); if (isAuth) textArea.setChoicesClosed(ChoiceAuthorityManager.getManager().isClosed(fieldKey)); if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) textArea.addError(dcInput.getWarning()); if (dcInput.isRepeatable() && !readonly) if ((dcInput.isRepeatable() || dcValues.length > 1) && !readonly) if (dcInput.isRepeatable() || dcValues.length > 1)
if (dcInput.isRepeatable()) listField.setLabel(dcInput.getLabel()); listField.setHelp(cleanHints(dcInput.getHints())); if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) listField.addError(dcInput.getWarning()); java.util.List<String> pairs = dcInput.getPairs(); for (int i = 0; i < pairs.size(); i += 2)
public String getFieldName() { return Utils.standardize(this.getSchema(), this.getElement(), this.getQualifier(), "."); }
text.setLabel(dcInput.getLabel()); text.setHelp(cleanHints(dcInput.getHints())); String fieldKey = MetadataAuthorityManager.makeFieldKey(dcInput.getSchema(), dcInput.getElement(), dcInput.getQualifier()); boolean isAuth = MetadataAuthorityManager.getManager().isAuthorityControlled(fieldKey); if (isAuth) if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) text.addError(dcInput.getWarning()); if (dcInput.isRepeatable() && !readonly) if ((dcInput.isRepeatable() || dcValues.length > 1) && !readonly) if (dcInput.isRepeatable() || dcValues.length > 1)
qualdrop.setLabel(dcInput.getLabel()); qualdrop.setHelp(cleanHints(dcInput.getHints())); if (dcInput.isRequired()) if (dcInput.getWarning() != null && dcInput.getWarning().length() > 0) qualdrop.addError(dcInput.getWarning()); if (dcInput.isRepeatable() && !readonly) if ((dcInput.isRepeatable() || dcValues.length > 1) && !readonly) java.util.List<String> pairs = dcInput.getPairs(); for (int i = 0; i < pairs.size(); i += 2) if (dcInput.isRepeatable() || dcValues.length > 1)
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()); ChoiceAuthority ca = controller.get(authorityName); if (ca == null) {
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; }
protected boolean isRepeatableMetadata(String formName, String[] md) { try { DCInput dcinput = getDCInput(formName, md[0], md[1], md[2]); if (dcinput != null) { return dcinput.isRepeatable(); } return true; } catch (Exception e) { e.printStackTrace(); } return false; }