mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-3699] finalizing refactoring; improved authority endpoint;
This commit is contained in:
@@ -154,23 +154,54 @@ public class DCInputsReader
|
||||
* if no default set defined
|
||||
* @throws ServletException
|
||||
*/
|
||||
public DCInputSet getInputsByCollectionHandle(String collectionHandle)
|
||||
public List<DCInputSet> getInputsByCollectionHandle(String collectionHandle)
|
||||
throws DCInputsReaderException
|
||||
{
|
||||
SubmissionConfig config;
|
||||
try {
|
||||
config = new SubmissionConfigReader().getSubmissionConfigByName(collectionHandle);
|
||||
config = new SubmissionConfigReader().getSubmissionConfigByCollection(collectionHandle);
|
||||
String formName = config.getSubmissionName();
|
||||
if (formName == null)
|
||||
{
|
||||
throw new DCInputsReaderException("No form designated as default");
|
||||
}
|
||||
return getInputsByFormName(formName);
|
||||
List<DCInputSet> results = new ArrayList<DCInputSet>();
|
||||
for (int idx = 0; idx < config.getNumberOfSteps(); idx++) {
|
||||
SubmissionStepConfig step = config.getStep(idx);
|
||||
if(SubmissionStepConfig.INPUT_FORM_STEP_NAME.equals(step.getType())) {
|
||||
results.add(getInputsByFormName(step.getId()));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
} catch (ServletException e) {
|
||||
throw new DCInputsReaderException("No form designated as default");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<DCInputSet> getInputsBySubmissionName(String name)
|
||||
throws DCInputsReaderException
|
||||
{
|
||||
SubmissionConfig config;
|
||||
try {
|
||||
config = new SubmissionConfigReader().getSubmissionConfigByName(name);
|
||||
String formName = config.getSubmissionName();
|
||||
if (formName == null)
|
||||
{
|
||||
throw new DCInputsReaderException("No form designated as default");
|
||||
}
|
||||
List<DCInputSet> results = new ArrayList<DCInputSet>();
|
||||
for (int idx = 0; idx < config.getNumberOfSteps(); idx++) {
|
||||
SubmissionStepConfig step = config.getStep(idx);
|
||||
if(SubmissionStepConfig.INPUT_FORM_STEP_NAME.equals(step.getType())) {
|
||||
results.add(getInputsByFormName(step.getId()));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
} catch (ServletException e) {
|
||||
throw new DCInputsReaderException("No form designated as default");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of DC inputs used for a particular input form
|
||||
*
|
||||
|
@@ -30,6 +30,9 @@ import java.io.Serializable;
|
||||
*/
|
||||
public class SubmissionStepConfig implements Serializable
|
||||
{
|
||||
|
||||
public static final String INPUT_FORM_STEP_NAME = "input-form";
|
||||
|
||||
/*
|
||||
* The identifier for the Select Collection step
|
||||
*/
|
||||
|
@@ -489,66 +489,57 @@ public class Util {
|
||||
// Read the input form file for the specific collection
|
||||
DCInputsReader inputsReader = new DCInputsReader(formFileName);
|
||||
|
||||
DCInputSet inputSet = inputsReader.getInputsByCollectionHandle(col_handle);
|
||||
List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);
|
||||
|
||||
// Replace the values of Metadatum[] with the correct ones in case of
|
||||
// controlled vocabularies
|
||||
String currentField = schema + "." + element
|
||||
+ (qualifier == null ? "" : "." + qualifier);
|
||||
for (DCInputSet inputSet : inputSets) {
|
||||
// Replace the values of Metadatum[] with the correct ones in case
|
||||
// of
|
||||
// controlled vocabularies
|
||||
String currentField = schema + "." + element + (qualifier == null ? "" : "." + qualifier);
|
||||
|
||||
if (inputSet != null)
|
||||
{
|
||||
if (inputSet != null) {
|
||||
|
||||
int fieldsNums = inputSet.getNumberFields();
|
||||
int fieldsNums = inputSet.getNumberFields();
|
||||
|
||||
for (int p = 0; p < fieldsNums; p++)
|
||||
{
|
||||
for (int p = 0; p < fieldsNums; p++) {
|
||||
|
||||
DCInput[] inputs = inputSet.getFields();
|
||||
DCInput[] inputs = inputSet.getFields();
|
||||
|
||||
if (inputs != null)
|
||||
{
|
||||
if (inputs != null) {
|
||||
|
||||
for (int i = 0; i < inputs.length; i++)
|
||||
{
|
||||
String inputField = inputs[i].getSchema()
|
||||
+ "."
|
||||
+ inputs[i].getElement()
|
||||
+ (inputs[i].getQualifier() == null ? "" : "."
|
||||
+ inputs[i].getQualifier());
|
||||
if (currentField.equals(inputField))
|
||||
{
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
String inputField = inputs[i].getSchema() + "." + inputs[i].getElement()
|
||||
+ (inputs[i].getQualifier() == null ? "" : "." + inputs[i].getQualifier());
|
||||
if (currentField.equals(inputField)) {
|
||||
|
||||
myInputs = inputs[i];
|
||||
myInputsFound = true;
|
||||
break;
|
||||
myInputs = inputs[i];
|
||||
myInputsFound = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myInputsFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myInputsFound)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (myInputsFound)
|
||||
{
|
||||
if (myInputsFound) {
|
||||
|
||||
for (MetadataValue value : values) {
|
||||
for (MetadataValue value : values) {
|
||||
|
||||
String pairsName = myInputs.getPairsType();
|
||||
String stored_value = value.getValue();
|
||||
String displayVal = myInputs.getDisplayString(pairsName,
|
||||
stored_value);
|
||||
String pairsName = myInputs.getPairsType();
|
||||
String stored_value = value.getValue();
|
||||
String displayVal = myInputs.getDisplayString(pairsName, stored_value);
|
||||
|
||||
if (displayVal != null && !"".equals(displayVal)) {
|
||||
if (displayVal != null && !"".equals(displayVal)) {
|
||||
|
||||
toReturn.add(displayVal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
toReturn.add(displayVal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content.authority;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ public class Choice
|
||||
/** The canonical text value to insert into MetadataValue's text field */
|
||||
public String value = null;
|
||||
|
||||
public Map<String, String> extras = null;
|
||||
public Map<String, String> extras = new HashMap<String, String>();
|
||||
|
||||
public Choice()
|
||||
{
|
||||
|
@@ -75,15 +75,15 @@ public interface ChoiceAuthority
|
||||
*/
|
||||
public String getLabel(String field, String key, String locale);
|
||||
|
||||
default public boolean isHierarchical() {
|
||||
default boolean isHierarchical() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default public boolean isScrollable() {
|
||||
default boolean isScrollable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default public boolean hasIdentifier() {
|
||||
default boolean hasIdentifier() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,4 +94,5 @@ public interface ChoiceAuthority
|
||||
result.value = getLabel(fieldKey, authKey, locale);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -206,32 +206,17 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHierarchical(String schema, String element, String qualifier) {
|
||||
String fieldKey = makeFieldKey(schema, element, qualifier);
|
||||
ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
|
||||
if (ma == null)
|
||||
{
|
||||
// throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\".");
|
||||
return false;
|
||||
}
|
||||
return ma.isHierarchical();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollable(String schema, String element, String qualifier) {
|
||||
String fieldKey = makeFieldKey(schema, element, qualifier);
|
||||
ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
|
||||
if (ma == null)
|
||||
{
|
||||
// throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\".");
|
||||
return false;
|
||||
}
|
||||
return ma.isScrollable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChoiceAuthorityName(String schema, String element, String qualifier) {
|
||||
String makeFieldKey = makeFieldKey(schema, element, qualifier);
|
||||
if(getChoiceAuthorityMap().containsKey(makeFieldKey)) {
|
||||
for(String key : this.authorities.keySet()) {
|
||||
if(this.authorities.get(key).equals(makeFieldKey)) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return configurationService.getProperty(
|
||||
CHOICES_PLUGIN_PREFIX + schema + "." + element + (qualifier != null ? "." + qualifier : ""));
|
||||
}
|
||||
@@ -316,18 +301,20 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
|
||||
ChoiceAuthority ca = controller.get(authorityName);
|
||||
if (ca == null) {
|
||||
InputFormSelfRegisterWrapperAuthority ifa = new InputFormSelfRegisterWrapperAuthority();
|
||||
if(controller.containsKey(fieldKey)) {
|
||||
ifa = (InputFormSelfRegisterWrapperAuthority)controller.get(fieldKey);
|
||||
}
|
||||
|
||||
ChoiceAuthority ma = (ChoiceAuthority)pluginService.getNamedPlugin(ChoiceAuthority.class, authorityName);
|
||||
if (ma == null) {
|
||||
log.warn("Skipping invalid configuration for " + fieldKey
|
||||
+ " because named plugin not found: " + authorityName);
|
||||
continue;
|
||||
}
|
||||
ifa.setDelegate(ma);
|
||||
ifa.getDelegates().put(dcinputSet.getFormName(), ma);
|
||||
controller.put(fieldKey, ifa);
|
||||
} else {
|
||||
ca = (InputFormSelfRegisterWrapperAuthority) ca;
|
||||
controller.put(fieldKey, ca);
|
||||
}
|
||||
}
|
||||
|
||||
if (!authorities.containsKey(authorityName)) {
|
||||
authorityNames.add(authorityName);
|
||||
authorities.put(authorityName, fieldKey);
|
||||
@@ -421,11 +408,15 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIdentifier(String schema, String element, String qualifier) {
|
||||
ChoiceAuthority ma = getChoiceAuthorityMap().get(makeFieldKey(schema, element, qualifier));
|
||||
if(ma == null) {
|
||||
return false;
|
||||
}
|
||||
return ma.hasIdentifier();
|
||||
public ChoiceAuthority getChoiceAuthorityByAuthorityName(String authorityName) {
|
||||
ChoiceAuthority ma = (ChoiceAuthority)
|
||||
pluginService.getNamedPlugin(ChoiceAuthority.class, authorityName);
|
||||
if (ma == null)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"No choices plugin was configured for authorityName \"" + authorityName
|
||||
+ "\".");
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
}
|
||||
|
@@ -7,27 +7,26 @@
|
||||
*/
|
||||
package org.dspace.content.authority;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* ChoiceAuthority source that reads the JSPUI-style hierarchical vocabularies
|
||||
@@ -63,6 +62,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
private static Logger log = Logger.getLogger(DSpaceControlledVocabulary.class);
|
||||
protected static String xpathTemplate = "//node[contains(translate(@label,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'%s')]";
|
||||
protected static String idTemplate = "//node[@id = '%s']";
|
||||
protected static String idParentTemplate = "//node[@id = '%s']/parent::isComposedBy";
|
||||
protected static String pluginNames[] = null;
|
||||
|
||||
protected String vocabularyName = null;
|
||||
@@ -177,29 +177,12 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
String[] authorities = new String[results.getLength()];
|
||||
String[] values = new String[results.getLength()];
|
||||
String[] labels = new String[results.getLength()];
|
||||
String[] parent = new String[results.getLength()];
|
||||
String[] notes = new String[results.getLength()];
|
||||
for (int i = 0; i < results.getLength(); i++)
|
||||
{
|
||||
Node node = results.item(i);
|
||||
String hierarchy = this.buildString(node);
|
||||
if (this.suggestHierarchy)
|
||||
{
|
||||
labels[i] = hierarchy;
|
||||
}
|
||||
else
|
||||
{
|
||||
labels[i] = node.getAttributes().getNamedItem("label").getNodeValue();
|
||||
}
|
||||
if (this.storeHierarchy)
|
||||
{
|
||||
values[i] = hierarchy;
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = node.getAttributes().getNamedItem("label").getNodeValue();
|
||||
}
|
||||
Node idAttr = node.getAttributes().getNamedItem("id");
|
||||
if (null != idAttr) // 'id' is optional
|
||||
authorities[i] = idAttr.getNodeValue();
|
||||
readNode(authorities, values, labels, parent, notes, i, node);
|
||||
}
|
||||
int resultCount = labels.length - start;
|
||||
if ((limit > 0) && (resultCount > limit)) // limit = 0 means no limit
|
||||
@@ -211,6 +194,12 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
{
|
||||
choices[i] = new Choice(authorities[start + i], values[start
|
||||
+ i], labels[start + i]);
|
||||
if(StringUtils.isNotBlank(parent[i])) {
|
||||
choices[i].extras.put("parent", parent[i]);
|
||||
}
|
||||
if(StringUtils.isNotBlank(notes[i])) {
|
||||
choices[i].extras.put("note", notes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(XPathExpressionException e) {
|
||||
@@ -219,6 +208,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
return new Choices(choices, 0, choices.length, Choices.CF_AMBIGUOUS, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Choices getBestMatch(String field, String text, Collection collection, String locale)
|
||||
{
|
||||
@@ -240,4 +230,96 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHierarchical() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choice getChoice(String fieldKey, String authKey, String locale) {
|
||||
init();
|
||||
log.debug("Getting matches for '" + authKey + "'");
|
||||
String xpathExpression = String.format(idTemplate, authKey);
|
||||
XPath xpath = XPathFactory.newInstance().newXPath();
|
||||
try {
|
||||
Node node = (Node) xpath.evaluate(xpathExpression, vocabulary, XPathConstants.NODE);
|
||||
if (node != null) {
|
||||
String[] authorities = new String[1];
|
||||
String[] values = new String[1];
|
||||
String[] labels = new String[1];
|
||||
String[] parent = new String[1];
|
||||
String[] note = new String[1];
|
||||
readNode(authorities, values, labels, parent, note, 0, node);
|
||||
|
||||
if (values.length > 0) {
|
||||
Choice choice = new Choice(authorities[0], values[0], labels[0]);
|
||||
if (StringUtils.isNotBlank(parent[0])) {
|
||||
choice.extras.put("parent", parent[0]);
|
||||
}
|
||||
if(StringUtils.isNotBlank(note[0])) {
|
||||
choice.extras.put("note", note[0]);
|
||||
}
|
||||
return choice;
|
||||
}
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
log.warn(e.getMessage(), e);
|
||||
}
|
||||
return new Choice("", "", "");
|
||||
}
|
||||
|
||||
|
||||
private void readNode(String[] authorities, String[] values, String[] labels, String[] parent, String[] notes, int i, Node node) {
|
||||
String hierarchy = this.buildString(node);
|
||||
if (this.suggestHierarchy)
|
||||
{
|
||||
labels[i] = hierarchy;
|
||||
}
|
||||
else
|
||||
{
|
||||
labels[i] = node.getAttributes().getNamedItem("label").getNodeValue();
|
||||
}
|
||||
if (this.storeHierarchy)
|
||||
{
|
||||
values[i] = hierarchy;
|
||||
}
|
||||
else
|
||||
{
|
||||
values[i] = node.getAttributes().getNamedItem("label").getNodeValue();
|
||||
}
|
||||
|
||||
NodeList childNodes = node.getChildNodes();
|
||||
for (int ci = 0; ci < childNodes.getLength(); ci++)
|
||||
{
|
||||
Node firstChild = childNodes.item(ci);
|
||||
if(firstChild!=null && "hasNote".equals(firstChild.getNodeName())) {
|
||||
String nodeValue = firstChild.getTextContent();
|
||||
if(StringUtils.isNotBlank(nodeValue)) {
|
||||
notes[i] = nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
Node idAttr = node.getAttributes().getNamedItem("id");
|
||||
if (null != idAttr) { // 'id' is optional
|
||||
authorities[i] = idAttr.getNodeValue();
|
||||
if(isHierarchical()) {
|
||||
Node parentN = node.getParentNode();
|
||||
if(parentN != null) {
|
||||
parentN = parentN.getParentNode();
|
||||
if (parentN != null) {
|
||||
Node parentIdAttr = parentN.getAttributes().getNamedItem("id");
|
||||
if (null != parentIdAttr) {
|
||||
parent[i] = parentIdAttr.getNodeValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
authorities[i] = null;
|
||||
parent[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,8 @@ package org.dspace.content.authority;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.Utils;
|
||||
|
||||
@@ -17,36 +19,95 @@ import org.dspace.core.Utils;
|
||||
* This authority is registered automatically by the ChoiceAuthorityService for
|
||||
* all the metadata that use a value-pair or a vocabulary in the input-form.xml
|
||||
*
|
||||
* It keeps a map of form-name vs ChoiceAuthority to delegate the execution of
|
||||
* the method to the specific ChoiceAuthority configured for the collection when
|
||||
* the same metadata have different vocabulary or value-pair on a collection
|
||||
* basis
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public class InputFormSelfRegisterWrapperAuthority implements ChoiceAuthority
|
||||
{
|
||||
private ChoiceAuthority delegate;
|
||||
public class InputFormSelfRegisterWrapperAuthority implements ChoiceAuthority {
|
||||
|
||||
@Override
|
||||
public Choices getMatches(String field, String query, Collection collection, int start, int limit, String locale)
|
||||
{
|
||||
return delegate.getMatches(field, query, collection, start, limit, locale);
|
||||
}
|
||||
private Map<String, ChoiceAuthority> delegates = new HashMap<String, ChoiceAuthority>();
|
||||
|
||||
@Override
|
||||
public Choices getBestMatch(String field, String text, Collection collection, String locale)
|
||||
{
|
||||
return delegate.getBestMatch(field, text, collection, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel(String field, String key, String locale)
|
||||
{
|
||||
return delegate.getLabel(field, key, locale);
|
||||
}
|
||||
|
||||
public ChoiceAuthority getDelegate() {
|
||||
return delegate;
|
||||
@Override
|
||||
public Choices getMatches(String field, String query, Collection collection, int start, int limit, String locale) {
|
||||
String formName;
|
||||
try {
|
||||
formName = Utils.getInputFormNameByCollectionAndField(collection, field);
|
||||
return delegates.get(formName).getMatches(field, query, collection, start, limit, locale);
|
||||
} catch (DCInputsReaderException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDelegate(ChoiceAuthority delegate) {
|
||||
this.delegate = delegate;
|
||||
@Override
|
||||
public Choices getBestMatch(String field, String text, Collection collection, String locale) {
|
||||
String formName;
|
||||
try {
|
||||
formName = Utils.getInputFormNameByCollectionAndField(collection, field);
|
||||
return delegates.get(formName).getBestMatch(field, text, collection, locale);
|
||||
} catch (DCInputsReaderException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel(String field, String key, String locale) {
|
||||
// TODO we need to manage REALLY the authority
|
||||
// WRONG BEHAVIOUR: now in each delegates can exists the same key with
|
||||
// different value
|
||||
for (ChoiceAuthority delegate : delegates.values()) {
|
||||
String label = delegate.getLabel(field, key, locale);
|
||||
if (StringUtils.isNotBlank(label)) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
return "UNKNOWN KEY " + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHierarchical() {
|
||||
// TODO we need to manage REALLY the authority
|
||||
// WRONG BEHAVIOUR: now in each delegates can exists the same key with
|
||||
// different value
|
||||
for (ChoiceAuthority delegate : delegates.values()) {
|
||||
return delegate.isHierarchical();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollable() {
|
||||
// TODO we need to manage REALLY the authority
|
||||
// WRONG BEHAVIOUR: now in each delegates can exists the same key with
|
||||
// different value
|
||||
for (ChoiceAuthority delegate : delegates.values()) {
|
||||
return delegate.isScrollable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIdentifier() {
|
||||
// TODO we need to manage REALLY the authority
|
||||
// WRONG BEHAVIOUR: now in each delegates can exists the same key with
|
||||
// different value
|
||||
for (ChoiceAuthority delegate : delegates.values()) {
|
||||
return delegate.hasIdentifier();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, ChoiceAuthority> getDelegates() {
|
||||
return delegates;
|
||||
}
|
||||
|
||||
public void setDelegates(Map<String, ChoiceAuthority> delegates) {
|
||||
this.delegates = delegates;
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ import org.dspace.content.authority.Choices;
|
||||
*/
|
||||
public interface ChoiceAuthorityService
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the names of all the defined choice authorities
|
||||
@@ -53,30 +54,6 @@ public interface ChoiceAuthorityService
|
||||
*
|
||||
*/
|
||||
public String getChoiceAuthorityName(String schema, String element, String qualifier);
|
||||
|
||||
/**
|
||||
* Wrapper that calls isHierachical method of the plugin corresponding to
|
||||
* the metadata field defined by schema,element,qualifier.
|
||||
*
|
||||
* @see org.dspace.content.authority.ChoiceAuthority#isHierachical()
|
||||
* @param schema schema of metadata field
|
||||
* @param element element of metadata field
|
||||
* @param qualifier qualifier of metadata field
|
||||
* @return true if the authority structure is hierachical
|
||||
*/
|
||||
public boolean isHierarchical(String schema, String element, String qualifier);
|
||||
|
||||
/**
|
||||
* Wrapper that calls isScrollable method of the plugin corresponding to
|
||||
* the metadata field defined by schema,element,qualifier.
|
||||
*
|
||||
* @see org.dspace.content.authority.ChoiceAuthority#isScrollable()
|
||||
* @param schema schema of metadata field
|
||||
* @param element element of metadata field
|
||||
* @param qualifier qualifier of metadata field
|
||||
* @return true if the authority can be scrolled other than searched
|
||||
*/
|
||||
public boolean isScrollable(String schema, String element, String qualifier);
|
||||
|
||||
/**
|
||||
* Wrapper that calls getMatches method of the plugin corresponding to
|
||||
@@ -181,6 +158,7 @@ public interface ChoiceAuthorityService
|
||||
public String getChoiceMetadatabyAuthorityName(String name);
|
||||
|
||||
public Choice getChoice(String fieldKey, String authKey, String locale);
|
||||
|
||||
public boolean hasIdentifier(String schema, String element, String qualifier);
|
||||
|
||||
public ChoiceAuthority getChoiceAuthorityByAuthorityName(String authorityName);
|
||||
|
||||
}
|
@@ -16,14 +16,28 @@ import java.math.BigInteger;
|
||||
import java.rmi.dgc.VMID;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.text.ParseException;
|
||||
import com.coverity.security.Escape;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.DCInput;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.content.Collection;
|
||||
|
||||
import com.coverity.security.Escape;
|
||||
|
||||
/**
|
||||
* Utility functions for DSpace.
|
||||
@@ -411,7 +425,50 @@ public final class Utils
|
||||
return result.substring(0, rl-2) + ":" + result.substring(rl-2);
|
||||
}
|
||||
|
||||
public static <E> Collection<E> emptyIfNull(Collection<E> collection) {
|
||||
public static <E> java.util.Collection<E> emptyIfNull(java.util.Collection<E> collection) {
|
||||
return collection == null ? Collections.<E>emptyList() : collection;
|
||||
}
|
||||
|
||||
public static String getInputFormNameByCollectionAndField(Collection collection, String field) throws DCInputsReaderException {
|
||||
DCInputsReader dcInputsReader = new DCInputsReader();
|
||||
List<DCInputSet> inputSets = dcInputsReader.getInputsByCollectionHandle(collection.getHandle());
|
||||
for (DCInputSet inputSet : inputSets) {
|
||||
String[] tokenized = tokenize(field);
|
||||
String element = tokenized[1];
|
||||
String qualifier = tokenized[2];
|
||||
if(StringUtils.isBlank(qualifier)) {
|
||||
qualifier = null;
|
||||
}
|
||||
if (inputSet.isFieldPresent(element+"."+qualifier)) {
|
||||
return inputSet.getFormName();
|
||||
}
|
||||
}
|
||||
throw new DCInputsReaderException("No field configuration found!");
|
||||
}
|
||||
|
||||
public static String[] tokenize(String metadata) {
|
||||
String separator = metadata.contains("_") ? "_" : ".";
|
||||
StringTokenizer dcf = new StringTokenizer(metadata, separator);
|
||||
|
||||
String[] tokens = { "", "", "" };
|
||||
int i = 0;
|
||||
while (dcf.hasMoreTokens()) {
|
||||
tokens[i] = dcf.nextToken().trim();
|
||||
i++;
|
||||
}
|
||||
// Tokens contains:
|
||||
// schema = tokens[0];
|
||||
// element = tokens[1];
|
||||
// qualifier = tokens[2];
|
||||
return tokens;
|
||||
|
||||
}
|
||||
|
||||
public static String standardize(String schema, String element, String qualifier, String separator) {
|
||||
if (StringUtils.isBlank(qualifier)) {
|
||||
return schema + separator + element;
|
||||
} else {
|
||||
return schema + separator + element + separator + qualifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -117,24 +117,23 @@ public class RequiredMetadata extends AbstractCurationTask
|
||||
if (reqList == null)
|
||||
{
|
||||
reqList = new ArrayList<String>();
|
||||
DCInputSet inputs = reader.getInputsByCollectionHandle(handle);
|
||||
for (DCInput input : inputs.getFields())
|
||||
{
|
||||
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);
|
||||
List<DCInputSet> inputSet = reader.getInputsByCollectionHandle(handle);
|
||||
for (DCInputSet inputs : inputSet) {
|
||||
for (DCInput input : inputs.getFields()) {
|
||||
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;
|
||||
}
|
||||
|
@@ -332,7 +332,8 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator
|
||||
protected DCInput getDCInput(String formName, String schema, String element,
|
||||
String qualifier) throws DCInputsReaderException
|
||||
{
|
||||
DCInputSet dcinputset = new DCInputsReader().getInputsByCollectionHandle(formName);
|
||||
List<DCInputSet> dcinputsets = new DCInputsReader().getInputsBySubmissionName(formName);
|
||||
for(DCInputSet dcinputset : dcinputsets) {
|
||||
for (DCInput dcinput : dcinputset.getFields())
|
||||
{
|
||||
if (dcinput.getSchema().equals(schema)
|
||||
@@ -344,6 +345,7 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator
|
||||
return dcinput;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -24,8 +24,11 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.DCInput;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.*;
|
||||
@@ -62,7 +65,8 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
|
||||
/** hash of all submission forms details */
|
||||
private static DCInputsReader inputsReader = null;
|
||||
|
||||
private static SubmissionConfigReader submissionConfigReader = null;
|
||||
|
||||
/***************************************************************************
|
||||
* STATUS / ERROR FLAGS (returned by doProcessing() if an error occurs or
|
||||
* additional user interaction may be required)
|
||||
@@ -93,6 +97,7 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
{
|
||||
//load the DCInputsReader
|
||||
getInputsReader();
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
metadataAuthorityService = ContentAuthorityServiceFactory.getInstance().getMetadataAuthorityService();
|
||||
choiceAuthorityService = ContentAuthorityServiceFactory.getInstance().getChoiceAuthorityService();
|
||||
}
|
||||
@@ -152,7 +157,13 @@ public class DescribeStep extends AbstractProcessingStep
|
||||
DCInput[] inputs = null;
|
||||
try
|
||||
{
|
||||
inputs = inputsReader.getInputsByCollectionHandle(c.getHandle()).getFields();
|
||||
List<DCInputSet> inputsByCollectionHandle = inputsReader.getInputsByCollectionHandle(c.getHandle());
|
||||
for(DCInputSet iset : inputsByCollectionHandle) {
|
||||
SubmissionStepConfig step = submissionConfigReader.getStepConfig(iset.getFormName());
|
||||
if(step.getStepNumber()==currentPage) {
|
||||
inputs = iset.getFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (DCInputsReaderException e)
|
||||
{
|
||||
|
@@ -28,7 +28,10 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionInfo;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -171,10 +174,10 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
else
|
||||
{
|
||||
// create our new Workspace Item
|
||||
DCInputSet inputSet = null;
|
||||
SubmissionConfig stepConfig = null;
|
||||
try
|
||||
{
|
||||
inputSet = new DCInputsReader().getInputsByCollectionHandle(col.getHandle());
|
||||
stepConfig = new SubmissionConfigReader().getSubmissionConfigByCollection(col.getHandle());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -245,7 +248,7 @@ public class StartSubmissionLookupStep extends AbstractProcessingStep
|
||||
.getOutputGenerator();
|
||||
outputGenerator.setCollection(col);
|
||||
outputGenerator.setContext(context);
|
||||
outputGenerator.setFormName(inputSet.getFormName());
|
||||
outputGenerator.setFormName(stepConfig.getSubmissionName());
|
||||
outputGenerator.setDto(dto.get(0));
|
||||
|
||||
try
|
||||
|
@@ -164,16 +164,16 @@ public class RestResourceController implements InitializingBean {
|
||||
LinkRest linkRest = utils.getLinkRest(rel, domainClass);
|
||||
if (linkRest != null) {
|
||||
LinkRestRepository linkRepository = utils.getLinkResourceRepository(apiCategory, model, linkRest.name());
|
||||
Method linkMethod = repositoryUtils.getLinkMethod("getKey", linkRepository);
|
||||
Method linkMethod = repositoryUtils.getLinkMethod("getResource", linkRepository);
|
||||
|
||||
try {
|
||||
Page<? extends Serializable> pageResult = (Page<? extends RestModel>) linkMethod
|
||||
.invoke(linkRepository, request, id, relid, page, projection);
|
||||
Object object = linkMethod.invoke(linkRepository, request, id, relid, page, projection);
|
||||
Link link = linkTo(this.getClass(), apiCategory, English.plural(model)).slash(id)
|
||||
.slash(rel).withSelfRel();
|
||||
PagedResources<? extends ResourceSupport> result = assembler
|
||||
.toResource(pageResult.map(linkRepository::wrapResource), link);
|
||||
return result;
|
||||
List result = new ArrayList();
|
||||
result.add(object);
|
||||
PageImpl<RestModel> pageResult = new PageImpl(result, page, 1);
|
||||
return assembler.toResource(pageResult.map(linkRepository::wrapResource),link);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.dspace.app.rest.model.AuthorityEntryRest;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This is the converter from/to the Choice in the DSpace API data
|
||||
* model and the REST data model.
|
||||
*
|
||||
* TODO please do not use this convert but use the wrapper {@link AuthorityUtils#convertEntry(Choice, String)}}
|
||||
*
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class AuthorityEntryRestConverter extends DSpaceConverter<Choice, AuthorityEntryRest> {
|
||||
|
||||
@Override
|
||||
public AuthorityEntryRest fromModel(Choice choice) {
|
||||
AuthorityEntryRest entry = new AuthorityEntryRest();
|
||||
entry.setValue(choice.value);
|
||||
entry.setDisplay(choice.label);
|
||||
entry.setId(choice.authority);
|
||||
entry.setOtherInformation(choice.extras);
|
||||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Choice toModel(AuthorityEntryRest obj) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.dspace.content.authority.ChoiceAuthority;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* This is the converter from/to the ChoiceAuthority in the DSpace API data
|
||||
* model and the REST data model
|
||||
*
|
||||
* TODO please do not use this convert but use the wrapper {@link AuthorityUtils#convertAuthority(ChoiceAuthority, String)}
|
||||
*
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class AuthorityRestConverter extends DSpaceConverter<ChoiceAuthority, AuthorityRest> {
|
||||
|
||||
@Override
|
||||
public AuthorityRest fromModel(ChoiceAuthority step) {
|
||||
AuthorityRest authorityRest = new AuthorityRest();
|
||||
authorityRest.setHierarchical(step.isHierarchical());
|
||||
authorityRest.setScrollable(step.isScrollable());
|
||||
authorityRest.setIdentifier(step.hasIdentifier());
|
||||
return authorityRest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChoiceAuthority toModel(AuthorityRest obj) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.model.SubmissionPanelRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -28,18 +28,18 @@ import org.springframework.stereotype.Component;
|
||||
public class SubmissionDefinitionConverter extends DSpaceConverter<SubmissionConfig, SubmissionDefinitionRest> {
|
||||
|
||||
@Autowired
|
||||
private SubmissionPanelConverter panelConverter;
|
||||
private SubmissionSectionConverter panelConverter;
|
||||
|
||||
@Override
|
||||
public SubmissionDefinitionRest fromModel(SubmissionConfig obj) {
|
||||
SubmissionDefinitionRest sd = new SubmissionDefinitionRest();
|
||||
sd.setName(obj.getSubmissionName());
|
||||
sd.setDefaultConf(obj.isDefaultConf());
|
||||
List<SubmissionPanelRest> panels = new LinkedList<SubmissionPanelRest>();
|
||||
List<SubmissionSectionRest> panels = new LinkedList<SubmissionSectionRest>();
|
||||
for (int idx = 0; idx < obj.getNumberOfSteps(); idx++) {
|
||||
SubmissionStepConfig step = obj.getStep(idx);
|
||||
if (step.isVisible()) {
|
||||
SubmissionPanelRest sp = panelConverter.convert(step);
|
||||
SubmissionSectionRest sp = panelConverter.convert(step);
|
||||
panels.add(sp);
|
||||
}
|
||||
}
|
||||
|
@@ -13,10 +13,10 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.rest.model.InputFormFieldRest;
|
||||
import org.dspace.app.rest.model.InputFormInputTypeRest;
|
||||
import org.dspace.app.rest.model.InputFormPageRest;
|
||||
import org.dspace.app.rest.model.InputFormRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormFieldRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormInputTypeRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormPageRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormRest;
|
||||
import org.dspace.app.rest.model.ScopeEnum;
|
||||
import org.dspace.app.rest.model.SelectableMetadata;
|
||||
import org.dspace.app.rest.model.SubmissionVisibilityRest;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRest> {
|
||||
public class SubmissionFormConverter extends DSpaceConverter<DCInputSet, SubmissionFormRest> {
|
||||
|
||||
private static final String INPUT_TYPE_ONEBOX = "onebox";
|
||||
private static final String INPUT_TYPE_NAME = "name";
|
||||
@@ -49,20 +49,20 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
private AuthorityUtils authorityUtils;
|
||||
|
||||
@Override
|
||||
public InputFormRest fromModel(DCInputSet obj) {
|
||||
InputFormRest sd = new InputFormRest();
|
||||
public SubmissionFormRest fromModel(DCInputSet obj) {
|
||||
SubmissionFormRest sd = new SubmissionFormRest();
|
||||
sd.setName(obj.getFormName());
|
||||
List<InputFormPageRest> pages = new LinkedList<InputFormPageRest>();
|
||||
List<SubmissionFormPageRest> pages = new LinkedList<SubmissionFormPageRest>();
|
||||
DCInput[] step = obj.getFields();
|
||||
InputFormPageRest sp = getPage(step);
|
||||
SubmissionFormPageRest sp = getPage(step);
|
||||
pages.add(sp);
|
||||
sd.setPages(pages);
|
||||
return sd;
|
||||
}
|
||||
|
||||
private InputFormPageRest getPage(DCInput[] page) {
|
||||
InputFormPageRest ifPage = new InputFormPageRest();
|
||||
List<InputFormFieldRest> fields = new LinkedList<InputFormFieldRest>();
|
||||
private SubmissionFormPageRest getPage(DCInput[] page) {
|
||||
SubmissionFormPageRest ifPage = new SubmissionFormPageRest();
|
||||
List<SubmissionFormFieldRest> fields = new LinkedList<SubmissionFormFieldRest>();
|
||||
for (DCInput dcinput : page) {
|
||||
fields.add(getField(dcinput));
|
||||
}
|
||||
@@ -70,11 +70,10 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
return ifPage;
|
||||
}
|
||||
|
||||
private InputFormFieldRest getField(DCInput dcinput) {
|
||||
InputFormFieldRest inputField = new InputFormFieldRest();
|
||||
private SubmissionFormFieldRest getField(DCInput dcinput) {
|
||||
SubmissionFormFieldRest inputField = new SubmissionFormFieldRest();
|
||||
List<SelectableMetadata> selectableMetadata = new ArrayList<SelectableMetadata>();
|
||||
|
||||
inputField.setSelectableMetadata(selectableMetadata);
|
||||
inputField.setLabel(dcinput.getLabel());
|
||||
inputField.setHints(dcinput.getHints());
|
||||
inputField.setMandatoryMessage(dcinput.getWarning());
|
||||
@@ -85,11 +84,11 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
VisibilityEnum.fromString(dcinput.isReadOnly("workflow")?"read-only":null)));
|
||||
inputField.setRepeatable(dcinput.isRepeatable());
|
||||
|
||||
InputFormInputTypeRest inputRest = new InputFormInputTypeRest();
|
||||
SubmissionFormInputTypeRest inputRest = new SubmissionFormInputTypeRest();
|
||||
|
||||
inputRest.setRegex(dcinput.getRegex());
|
||||
|
||||
if (!StringUtils.equalsIgnoreCase(inputRest.getType(), "qualdrop_value")) {
|
||||
if (!StringUtils.equalsIgnoreCase(dcinput.getInputType(), "qualdrop_value")) {
|
||||
// value-pair and vocabulary are a special kind of authorities
|
||||
String inputType = dcinput.getInputType();
|
||||
|
||||
@@ -98,7 +97,7 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
inputRest.setType(getPresentation(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier(), inputType));
|
||||
selMd.setAuthority(
|
||||
authorityUtils.getAuthorityName(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier()));
|
||||
selMd.setClosed(authorityUtils.isClosed(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier()));
|
||||
selMd.setClosed(authorityUtils.isClosed(dcinput.getSchema(), dcinput.getElement(), dcinput.getQualifier()));
|
||||
}
|
||||
else {
|
||||
inputRest.setType(inputType);
|
||||
@@ -120,8 +119,9 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
}
|
||||
selectableMetadata.add(selMd);
|
||||
}
|
||||
}
|
||||
}
|
||||
inputField.setInput(inputRest);
|
||||
inputField.setSelectableMetadata(selectableMetadata);
|
||||
return inputField;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class InputFormConverter extends DSpaceConverter<DCInputSet, InputFormRes
|
||||
}
|
||||
|
||||
@Override
|
||||
public DCInputSet toModel(InputFormRest obj) {
|
||||
public DCInputSet toModel(SubmissionFormRest obj) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
package org.dspace.app.rest.converter;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.dspace.app.rest.model.SubmissionPanelRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.model.SubmissionVisibilityRest;
|
||||
import org.dspace.app.rest.model.VisibilityEnum;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
@@ -21,14 +21,14 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*/
|
||||
@Component
|
||||
public class SubmissionPanelConverter extends DSpaceConverter<SubmissionStepConfig, SubmissionPanelRest> {
|
||||
public class SubmissionSectionConverter extends DSpaceConverter<SubmissionStepConfig, SubmissionSectionRest> {
|
||||
|
||||
@Override
|
||||
public SubmissionPanelRest fromModel(SubmissionStepConfig step) {
|
||||
SubmissionPanelRest sp = new SubmissionPanelRest();
|
||||
public SubmissionSectionRest fromModel(SubmissionStepConfig step) {
|
||||
SubmissionSectionRest sp = new SubmissionSectionRest();
|
||||
sp.setMandatory(step.isMandatory());
|
||||
sp.setHeader(step.getHeading());
|
||||
sp.setPanelType(step.getType());
|
||||
sp.setSectionType(step.getType());
|
||||
sp.setId(step.getId());
|
||||
sp.setVisibility(new SubmissionVisibilityRest(VisibilityEnum.fromString(step.getVisibility()),
|
||||
VisibilityEnum.fromString(step.getVisibilityOutside())));
|
||||
@@ -36,7 +36,7 @@ public class SubmissionPanelConverter extends DSpaceConverter<SubmissionStepConf
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubmissionStepConfig toModel(SubmissionPanelRest obj) {
|
||||
public SubmissionStepConfig toModel(SubmissionSectionRest obj) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@@ -7,24 +7,27 @@
|
||||
*/
|
||||
package org.dspace.app.rest.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* The Authority Entry REST Resource
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class AuthorityEntryRest implements Serializable {
|
||||
public class AuthorityEntryRest implements RestModel {
|
||||
public static final String NAME = "authorityEntry";
|
||||
private String id;
|
||||
private String display;
|
||||
private String value;
|
||||
private long count;
|
||||
private Map<String, String> otherInformation;
|
||||
private AuthorityEntryRest parent;
|
||||
|
||||
@JsonIgnore
|
||||
private String authorityName;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -32,39 +35,44 @@ public class AuthorityEntryRest implements Serializable {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
public void setDisplay(String value) {
|
||||
this.display = value;
|
||||
}
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
public Map<String, String> getOtherInformation() {
|
||||
return otherInformation;
|
||||
}
|
||||
public void setOtherInformation(Map<String, String> otherInformation) {
|
||||
this.otherInformation = otherInformation;
|
||||
}
|
||||
public AuthorityEntryRest getParent() {
|
||||
return parent;
|
||||
}
|
||||
public void setParent(AuthorityEntryRest parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
public static String getName() {
|
||||
return NAME;
|
||||
}
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public static String getName() {
|
||||
return NAME;
|
||||
}
|
||||
public String getAuthorityName() {
|
||||
return authorityName;
|
||||
}
|
||||
public void setAuthorityName(String authorityName) {
|
||||
this.authorityName = authorityName;
|
||||
}
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return AuthorityRest.CATEGORY;
|
||||
}
|
||||
@Override
|
||||
public String getType() {
|
||||
return AuthorityRest.NAME;
|
||||
}
|
||||
@Override
|
||||
public Class getController() {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,15 +16,15 @@ import org.dspace.app.rest.RestResourceController;
|
||||
*
|
||||
*/
|
||||
@LinksRest(links = {
|
||||
@LinkRest(name = AuthorityRest.ENTRIES, linkClass = AuthorityEntryRest.class, method = "listAuthorityEntries", optional = true),
|
||||
@LinkRest(name = AuthorityRest.ENTRY, linkClass = AuthorityEntryRest.class, method = "listAuthorityEntry", optional = true)
|
||||
@LinkRest(name = AuthorityRest.ENTRIES, linkClass = AuthorityEntryRest.class, method = "query", optional = true),
|
||||
@LinkRest(name = AuthorityRest.ENTRY, linkClass = AuthorityEntryRest.class, method = "getResource", optional = true)
|
||||
})
|
||||
public class AuthorityRest extends BaseObjectRest<String> {
|
||||
|
||||
public static final String NAME = "authority";
|
||||
public static final String CATEGORY = RestModel.INTEGRATION;
|
||||
public static final String ENTRIES = "entries";
|
||||
public static final String ENTRY = "entry";
|
||||
public static final String ENTRY = "entryValues";
|
||||
|
||||
private String name;
|
||||
|
||||
|
@@ -31,7 +31,7 @@ public class SubmissionDefinitionRest extends BaseObjectRest<String> {
|
||||
@JsonProperty(value="isDefault")
|
||||
private boolean defaultConf;
|
||||
|
||||
private List<SubmissionPanelRest> panels;
|
||||
private List<SubmissionSectionRest> panels;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@@ -46,13 +46,13 @@ public class SubmissionDefinitionRest extends BaseObjectRest<String> {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPanels(List<SubmissionPanelRest> panels) {
|
||||
public void setPanels(List<SubmissionSectionRest> panels) {
|
||||
this.panels = panels;
|
||||
}
|
||||
|
||||
@LinkRest(name=SubmissionPanelRest.NAME, linkClass = SubmissionPanelRest.class)
|
||||
@LinkRest(name=SubmissionSectionRest.NAME, linkClass = SubmissionSectionRest.class)
|
||||
@JsonIgnore
|
||||
public List<SubmissionPanelRest> getPanels() {
|
||||
public List<SubmissionSectionRest> getPanels() {
|
||||
return panels;
|
||||
}
|
||||
|
||||
|
@@ -21,13 +21,13 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
*
|
||||
*/
|
||||
@JsonInclude(value = Include.NON_NULL)
|
||||
public class InputFormFieldRest {
|
||||
public class SubmissionFormFieldRest {
|
||||
private String label;
|
||||
private boolean mandatory;
|
||||
private boolean repeatable;
|
||||
private String mandatoryMessage;
|
||||
private String hints;
|
||||
private InputFormInputTypeRest input;
|
||||
private SubmissionFormInputTypeRest input;
|
||||
private ScopeEnum scope;
|
||||
private SubmissionVisibilityRest visibility;
|
||||
private List<SelectableMetadata> selectableMetadata;
|
||||
@@ -80,11 +80,11 @@ public class InputFormFieldRest {
|
||||
this.hints = hints;
|
||||
}
|
||||
|
||||
public InputFormInputTypeRest getInput() {
|
||||
public SubmissionFormInputTypeRest getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public void setInput(InputFormInputTypeRest input) {
|
||||
public void setInput(SubmissionFormInputTypeRest input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
*
|
||||
*/
|
||||
@JsonInclude(value = Include.NON_NULL)
|
||||
public class InputFormInputTypeRest {
|
||||
public class SubmissionFormInputTypeRest {
|
||||
private String type;
|
||||
private String regex;
|
||||
private AuthorityRest authority;
|
||||
|
@@ -25,10 +25,10 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
*
|
||||
*/
|
||||
@JsonInclude(value=Include.NON_NULL)
|
||||
public class InputFormPageRest {
|
||||
public class SubmissionFormPageRest {
|
||||
private String header;
|
||||
private boolean mandatory;
|
||||
private List<InputFormFieldRest> fields;
|
||||
private List<SubmissionFormFieldRest> fields;
|
||||
|
||||
public String getHeader() {
|
||||
return header;
|
||||
@@ -46,18 +46,18 @@ public class InputFormPageRest {
|
||||
this.mandatory = mandatory;
|
||||
}
|
||||
|
||||
public List<InputFormFieldRest> getFields() {
|
||||
public List<SubmissionFormFieldRest> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setFields(List<InputFormFieldRest> fields) {
|
||||
public void setFields(List<SubmissionFormFieldRest> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ScopeEnum getScope() {
|
||||
ScopeEnum scope = fields.get(0).getScope();
|
||||
for (InputFormFieldRest field : fields) {
|
||||
for (SubmissionFormFieldRest field : fields) {
|
||||
if (!Objects.equals(field.getScope(), scope)) {
|
||||
return null;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class InputFormPageRest {
|
||||
@JsonIgnore
|
||||
public SubmissionVisibilityRest getVisibility() {
|
||||
SubmissionVisibilityRest visibility = fields.get(0).getVisibility();
|
||||
for (InputFormFieldRest field : fields) {
|
||||
for (SubmissionFormFieldRest field : fields) {
|
||||
if (!Objects.equals(field.getVisibility(), visibility)) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -19,14 +19,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
public class InputFormRest extends BaseObjectRest<String> {
|
||||
public class SubmissionFormRest extends BaseObjectRest<String> {
|
||||
public static final String NAME = "submission-form";
|
||||
public static final String NAME_LINK_ON_PANEL = RestModel.CONFIGURATION;
|
||||
public static final String CATEGORY = RestModel.CONFIGURATION;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<InputFormPageRest> pages;
|
||||
private List<SubmissionFormPageRest> pages;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@@ -41,11 +41,11 @@ public class InputFormRest extends BaseObjectRest<String> {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPages(List<InputFormPageRest> pages) {
|
||||
public void setPages(List<SubmissionFormPageRest> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public List<InputFormPageRest> getPages() {
|
||||
public List<SubmissionFormPageRest> getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
|
@@ -23,12 +23,12 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
*
|
||||
*/
|
||||
@JsonInclude(value=Include.NON_NULL)
|
||||
public class SubmissionPanelRest extends BaseObjectRest<String> {
|
||||
public class SubmissionSectionRest extends BaseObjectRest<String> {
|
||||
|
||||
public static final String NAME = "submission-panel";
|
||||
public static final String NAME = "submission-section";
|
||||
private String header;
|
||||
private boolean mandatory;
|
||||
private String panelType;
|
||||
private String sectionType;
|
||||
private ScopeEnum scope;
|
||||
private SubmissionVisibilityRest visibility;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SubmissionPanelRest extends BaseObjectRest<String> {
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return "submission-panel";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public ScopeEnum getScope() {
|
||||
@@ -80,12 +80,12 @@ public class SubmissionPanelRest extends BaseObjectRest<String> {
|
||||
return RestResourceController.class;
|
||||
}
|
||||
|
||||
public String getPanelType() {
|
||||
return panelType;
|
||||
public String getSectionType() {
|
||||
return sectionType;
|
||||
}
|
||||
|
||||
public void setPanelType(String panelType) {
|
||||
this.panelType = panelType;
|
||||
public void setSectionType(String panelType) {
|
||||
this.sectionType = panelType;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -7,29 +7,49 @@
|
||||
*/
|
||||
package org.dspace.app.rest.model.hateoas;
|
||||
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
import org.dspace.app.rest.model.AuthorityEntryRest;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
/**
|
||||
* Authority Rest HAL Resource. The HAL Resource wraps the REST Resource
|
||||
* adding support for the links and embedded resources
|
||||
* Authority Rest HAL Resource. The HAL Resource wraps the REST Resource adding
|
||||
* support for the links and embedded resources
|
||||
*
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*
|
||||
*/
|
||||
@RelNameDSpaceResource(AuthorityEntryRest.NAME)
|
||||
public class AuthorityEntryResource extends ResourceSupport {
|
||||
|
||||
|
||||
@JsonUnwrapped
|
||||
private final AuthorityEntryRest data;
|
||||
|
||||
public AuthorityEntryResource(AuthorityEntryRest entry) {
|
||||
|
||||
public AuthorityEntryResource(AuthorityEntryRest entry) {
|
||||
this.data = entry;
|
||||
if (entry.getOtherInformation() != null) {
|
||||
if (entry.getOtherInformation().containsKey(AuthorityUtils.RESERVED_KEYMAP_PARENT)) {
|
||||
RestResourceController methodOn = methodOn(RestResourceController.class, AuthorityRest.CATEGORY,
|
||||
AuthorityRest.NAME);
|
||||
UriComponentsBuilder uriComponentsBuilder = linkTo(methodOn.findRel(null, AuthorityRest.CATEGORY,
|
||||
English.plural(AuthorityRest.NAME), entry.getAuthorityName() + "/" + AuthorityRest.ENTRY,
|
||||
entry.getOtherInformation().get(AuthorityUtils.RESERVED_KEYMAP_PARENT), null, null, null)).toUriComponentsBuilder();
|
||||
Link link = new Link(uriComponentsBuilder.build().toString(), AuthorityUtils.RESERVED_KEYMAP_PARENT);
|
||||
add(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AuthorityEntryRest getData() {
|
||||
return data;
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest.model.hateoas;
|
||||
|
||||
import org.dspace.app.rest.model.InputFormRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
|
||||
@@ -18,9 +18,9 @@ import org.dspace.app.rest.utils.Utils;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
@RelNameDSpaceResource(InputFormRest.NAME)
|
||||
public class InputFormResource extends DSpaceResource<InputFormRest> {
|
||||
public InputFormResource(InputFormRest sd, Utils utils, String... rels) {
|
||||
@RelNameDSpaceResource(SubmissionFormRest.NAME)
|
||||
public class SubmissionFormResource extends DSpaceResource<SubmissionFormRest> {
|
||||
public SubmissionFormResource(SubmissionFormRest sd, Utils utils, String... rels) {
|
||||
super(sd, utils, rels);
|
||||
}
|
||||
}
|
@@ -12,8 +12,8 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.dspace.app.rest.RestResourceController;
|
||||
import org.dspace.app.rest.model.InputFormRest;
|
||||
import org.dspace.app.rest.model.SubmissionPanelRest;
|
||||
import org.dspace.app.rest.model.SubmissionFormRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.model.hateoas.annotations.RelNameDSpaceResource;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
import org.springframework.hateoas.Link;
|
||||
@@ -26,18 +26,18 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*
|
||||
*/
|
||||
@RelNameDSpaceResource(SubmissionPanelRest.NAME)
|
||||
public class SubmissionPanelResource extends DSpaceResource<SubmissionPanelRest> {
|
||||
@RelNameDSpaceResource(SubmissionSectionRest.NAME)
|
||||
public class SubmissionSectionResource extends DSpaceResource<SubmissionSectionRest> {
|
||||
|
||||
public SubmissionPanelResource(SubmissionPanelRest sd, Utils utils, String... rels) {
|
||||
public SubmissionSectionResource(SubmissionSectionRest sd, Utils utils, String... rels) {
|
||||
super(sd, utils, rels);
|
||||
if("input-form".equals(sd.getPanelType())) {
|
||||
RestResourceController methodOn = methodOn(RestResourceController.class, InputFormRest.CATEGORY, InputFormRest.NAME);
|
||||
if("input-form".equals(sd.getSectionType())) {
|
||||
RestResourceController methodOn = methodOn(RestResourceController.class, SubmissionFormRest.CATEGORY, SubmissionFormRest.NAME);
|
||||
UriComponentsBuilder uriComponentsBuilder = linkTo(methodOn
|
||||
.findRel(null, InputFormRest.CATEGORY, English.plural(InputFormRest.NAME), sd.getId(), "", null, null, null))
|
||||
.findRel(null, SubmissionFormRest.CATEGORY, English.plural(SubmissionFormRest.NAME), sd.getId(), "", null, null, null))
|
||||
.toUriComponentsBuilder();
|
||||
String uribuilder = uriComponentsBuilder.build().toString();
|
||||
Link link = new Link(uribuilder.substring(0, uribuilder.lastIndexOf("/")), InputFormRest.NAME_LINK_ON_PANEL);
|
||||
Link link = new Link(uribuilder.substring(0, uribuilder.lastIndexOf("/")), SubmissionFormRest.NAME_LINK_ON_PANEL);
|
||||
add(link);
|
||||
}
|
||||
}
|
||||
|
@@ -8,18 +8,22 @@
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.rest.converter.AuthorityEntryRestConverter;
|
||||
import org.dspace.app.rest.model.AuthorityEntryRest;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.app.rest.model.hateoas.AuthorityEntryResource;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.dspace.content.authority.Choices;
|
||||
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,17 +43,21 @@ import org.springframework.stereotype.Component;
|
||||
public class AuthorityEntryLinkRepository extends AbstractDSpaceRestRepository
|
||||
implements LinkRestRepository<AuthorityEntryRest> {
|
||||
|
||||
@Autowired
|
||||
private ChoiceAuthorityService cas;
|
||||
|
||||
@Autowired
|
||||
private CollectionService cs;
|
||||
|
||||
@Autowired
|
||||
private AuthorityUtils authorityUtils;
|
||||
|
||||
CollectionService cs = ContentServiceFactory.getInstance().getCollectionService();
|
||||
|
||||
@Override
|
||||
public ResourceSupport wrapResource(AuthorityEntryRest model, String... rels) {
|
||||
return new AuthorityEntryResource(model);
|
||||
}
|
||||
|
||||
public Page<AuthorityEntryRest> listAuthorityEntries(HttpServletRequest request, String name,
|
||||
public Page<AuthorityEntryRest> query(HttpServletRequest request, String name,
|
||||
Pageable pageable, String projection) {
|
||||
Context context = obtainContext();
|
||||
String query = request.getParameter("query");
|
||||
@@ -62,18 +70,17 @@ public class AuthorityEntryLinkRepository extends AbstractDSpaceRestRepository
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
List<AuthorityEntryRest> results = new ArrayList<AuthorityEntryRest>();
|
||||
if(StringUtils.isNotBlank(metadata)) {
|
||||
String[] tokens = org.dspace.core.Utils.tokenize(metadata);
|
||||
String fieldKey = org.dspace.core.Utils.standardize(tokens[0], tokens[1], tokens[2], "_");
|
||||
Choices choices = cas.getMatches(fieldKey, query, collection, pageable.getOffset(), pageable.getPageSize(), context.getCurrentLocale().toString());
|
||||
for (Choice value : choices.values) {
|
||||
results.add(authorityUtils.convertEntry(value, name));
|
||||
}
|
||||
}
|
||||
List<AuthorityEntryRest> authorities = authorityUtils.query(metadata, query, collection, pageable.getOffset(), pageable.getPageSize(), context.getCurrentLocale());
|
||||
return new PageImpl<AuthorityEntryRest>(authorities, pageable, authorities.size());
|
||||
}
|
||||
|
||||
|
||||
public AuthorityEntryRest listAuthorityEntry(HttpServletRequest request, String name,
|
||||
Pageable pageable, String projection) {
|
||||
Context context = obtainContext();
|
||||
String metadata = request.getParameter("metadata");
|
||||
String authKey = request.getParameter("key");
|
||||
return authorityUtils.get(metadata, authKey, context.getCurrentLocale().toString());
|
||||
return new PageImpl<AuthorityEntryRest>(results, pageable, results.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.converter.AuthorityEntryRestConverter;
|
||||
import org.dspace.app.rest.model.AuthorityEntryRest;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.app.rest.model.hateoas.AuthorityEntryResource;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.dspace.content.authority.ChoiceAuthority;
|
||||
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Controller for exposition of authority services
|
||||
*
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*
|
||||
*/
|
||||
@Component(AuthorityRest.CATEGORY + "." + AuthorityRest.NAME + "." + AuthorityRest.ENTRY)
|
||||
public class AuthorityEntryValueLinkRepository extends AbstractDSpaceRestRepository
|
||||
implements LinkRestRepository<AuthorityEntryRest> {
|
||||
|
||||
@Autowired
|
||||
private ChoiceAuthorityService cas;
|
||||
|
||||
@Autowired
|
||||
private AuthorityUtils authorityUtils;
|
||||
|
||||
@Override
|
||||
public ResourceSupport wrapResource(AuthorityEntryRest model, String... rels) {
|
||||
return new AuthorityEntryResource(model);
|
||||
}
|
||||
|
||||
public AuthorityEntryRest getResource(HttpServletRequest request, String name, String relId,
|
||||
Pageable pageable, String projection) {
|
||||
Context context = obtainContext();
|
||||
ChoiceAuthority choiceAuthority = cas.getChoiceAuthorityByAuthorityName(name);
|
||||
Choice choice = choiceAuthority.getChoice(null, relId, context.getCurrentLocale().toString());
|
||||
return authorityUtils.convertEntry(choice, name);
|
||||
}
|
||||
|
||||
}
|
@@ -7,11 +7,17 @@
|
||||
*/
|
||||
package org.dspace.app.rest.repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.dspace.app.rest.converter.AuthorityRestConverter;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.app.rest.model.hateoas.AuthorityResource;
|
||||
import org.dspace.app.rest.utils.AuthorityUtils;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.dspace.content.authority.ChoiceAuthority;
|
||||
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||
import org.dspace.core.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -27,23 +33,30 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component(AuthorityRest.CATEGORY + "." + AuthorityRest.NAME)
|
||||
public class AuthorityRestRepository extends DSpaceRestRepository<AuthorityRest, String> {
|
||||
|
||||
@Autowired
|
||||
private ChoiceAuthorityService cas;
|
||||
|
||||
@Autowired
|
||||
private AuthorityUtils authorityUtils;
|
||||
|
||||
@Override
|
||||
public AuthorityRest findOne(Context context, String name) {
|
||||
AuthorityRest authorityRest = authorityUtils.getAuthority(name);
|
||||
if(authorityRest == null) {
|
||||
return null;
|
||||
}
|
||||
return authorityRest;
|
||||
ChoiceAuthority source = cas.getChoiceAuthorityByAuthorityName(name);
|
||||
AuthorityRest result = authorityUtils.convertAuthority(source, name);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<AuthorityRest> findAll(Context context, Pageable pageable) {
|
||||
List<AuthorityRest> authorities = authorityUtils.getAuthorities();
|
||||
return new PageImpl<AuthorityRest>(authorities, pageable, authorities.size());
|
||||
Set<String> authoritiesName = cas.getChoiceAuthoritiesNames();
|
||||
List<AuthorityRest> results = new ArrayList<AuthorityRest>();
|
||||
for(String authorityName : authoritiesName) {
|
||||
ChoiceAuthority source = cas.getChoiceAuthorityByAuthorityName(authorityName);
|
||||
AuthorityRest result = authorityUtils.convertAuthority(source, authorityName);
|
||||
results.add(result);
|
||||
}
|
||||
return new PageImpl<AuthorityRest>(results, pageable, results.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -10,9 +10,9 @@ package org.dspace.app.rest.repository;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.converter.InputFormConverter;
|
||||
import org.dspace.app.rest.model.InputFormRest;
|
||||
import org.dspace.app.rest.model.hateoas.InputFormResource;
|
||||
import org.dspace.app.rest.converter.SubmissionFormConverter;
|
||||
import org.dspace.app.rest.model.SubmissionFormRest;
|
||||
import org.dspace.app.rest.model.hateoas.SubmissionFormResource;
|
||||
import org.dspace.app.util.DCInputSet;
|
||||
import org.dspace.app.util.DCInputsReader;
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
@@ -29,20 +29,20 @@ import org.springframework.stereotype.Component;
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*
|
||||
*/
|
||||
@Component(InputFormRest.CATEGORY + "." + InputFormRest.NAME)
|
||||
public class InputFormRestRepository extends DSpaceRestRepository<InputFormRest, String> implements LinkRestRepository<InputFormRest> {
|
||||
@Component(SubmissionFormRest.CATEGORY + "." + SubmissionFormRest.NAME)
|
||||
public class SubmissionFormRestRepository extends DSpaceRestRepository<SubmissionFormRest, String> implements LinkRestRepository<SubmissionFormRest> {
|
||||
|
||||
private DCInputsReader inputReader;
|
||||
|
||||
@Autowired
|
||||
private InputFormConverter converter;
|
||||
private SubmissionFormConverter converter;
|
||||
|
||||
public InputFormRestRepository() throws DCInputsReaderException {
|
||||
public SubmissionFormRestRepository() throws DCInputsReaderException {
|
||||
inputReader = new DCInputsReader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputFormRest findOne(Context context, String submitName) {
|
||||
public SubmissionFormRest findOne(Context context, String submitName) {
|
||||
DCInputSet inputConfig;
|
||||
try {
|
||||
inputConfig = inputReader.getInputsByFormName(submitName);
|
||||
@@ -56,7 +56,7 @@ public class InputFormRestRepository extends DSpaceRestRepository<InputFormRest,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InputFormRest> findAll(Context context, Pageable pageable) {
|
||||
public Page<SubmissionFormRest> findAll(Context context, Pageable pageable) {
|
||||
List<DCInputSet> subConfs = new ArrayList<DCInputSet>();
|
||||
int total = inputReader.countInputs();
|
||||
try {
|
||||
@@ -64,17 +64,17 @@ public class InputFormRestRepository extends DSpaceRestRepository<InputFormRest,
|
||||
} catch (DCInputsReaderException e) {
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
Page<InputFormRest> page = new PageImpl<DCInputSet>(subConfs, pageable, total).map(converter);
|
||||
Page<SubmissionFormRest> page = new PageImpl<DCInputSet>(subConfs, pageable, total).map(converter);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<InputFormRest> getDomainClass() {
|
||||
return InputFormRest.class;
|
||||
public Class<SubmissionFormRest> getDomainClass() {
|
||||
return SubmissionFormRest.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputFormResource wrapResource(InputFormRest sd, String... rels) {
|
||||
return new InputFormResource(sd, utils, rels);
|
||||
public SubmissionFormResource wrapResource(SubmissionFormRest sd, String... rels) {
|
||||
return new SubmissionFormResource(sd, utils, rels);
|
||||
}
|
||||
}
|
@@ -12,10 +12,10 @@ import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.dspace.app.rest.converter.SubmissionPanelConverter;
|
||||
import org.dspace.app.rest.converter.SubmissionSectionConverter;
|
||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.model.SubmissionPanelRest;
|
||||
import org.dspace.app.rest.model.hateoas.SubmissionPanelResource;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.model.hateoas.SubmissionSectionResource;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
@@ -32,20 +32,20 @@ import org.springframework.stereotype.Component;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*
|
||||
*/
|
||||
@Component(SubmissionDefinitionRest.CATEGORY + "." + SubmissionPanelRest.NAME)
|
||||
public class SubmissionPanelRestRepository extends DSpaceRestRepository<SubmissionPanelRest, String> {
|
||||
@Component(SubmissionDefinitionRest.CATEGORY + "." + SubmissionSectionRest.NAME)
|
||||
public class SubmissionPanelRestRepository extends DSpaceRestRepository<SubmissionSectionRest, String> {
|
||||
|
||||
private SubmissionConfigReader submissionConfigReader;
|
||||
|
||||
@Autowired
|
||||
private SubmissionPanelConverter converter;
|
||||
private SubmissionSectionConverter converter;
|
||||
|
||||
public SubmissionPanelRestRepository() throws ServletException {
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubmissionPanelRest findOne(Context context, String id) {
|
||||
public SubmissionSectionRest findOne(Context context, String id) {
|
||||
try {
|
||||
SubmissionStepConfig step = submissionConfigReader.getStepConfig(id);
|
||||
return converter.convert(step);
|
||||
@@ -56,7 +56,7 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SubmissionPanelRest> findAll(Context context, Pageable pageable) {
|
||||
public Page<SubmissionSectionRest> findAll(Context context, Pageable pageable) {
|
||||
List<SubmissionConfig> subConfs = new ArrayList<SubmissionConfig>();
|
||||
subConfs = submissionConfigReader.getAllSubmissionConfigs(pageable.getPageSize(), pageable.getOffset());
|
||||
int total = 0;
|
||||
@@ -68,18 +68,18 @@ public class SubmissionPanelRestRepository extends DSpaceRestRepository<Submissi
|
||||
stepConfs.add(step);
|
||||
}
|
||||
}
|
||||
Page<SubmissionPanelRest> page = new PageImpl<SubmissionStepConfig>(stepConfs, pageable, total).map(converter);
|
||||
Page<SubmissionSectionRest> page = new PageImpl<SubmissionStepConfig>(stepConfs, pageable, total).map(converter);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<SubmissionPanelRest> getDomainClass() {
|
||||
return SubmissionPanelRest.class;
|
||||
public Class<SubmissionSectionRest> getDomainClass() {
|
||||
return SubmissionSectionRest.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubmissionPanelResource wrapResource(SubmissionPanelRest model, String... rels) {
|
||||
return new SubmissionPanelResource(model, utils, rels);
|
||||
public SubmissionSectionResource wrapResource(SubmissionSectionRest model, String... rels) {
|
||||
return new SubmissionSectionResource(model, utils, rels);
|
||||
}
|
||||
|
||||
}
|
@@ -7,20 +7,13 @@
|
||||
*/
|
||||
package org.dspace.app.rest.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.rest.converter.AuthorityEntryRestConverter;
|
||||
import org.dspace.app.rest.converter.AuthorityRestConverter;
|
||||
import org.dspace.app.rest.model.AuthorityEntryRest;
|
||||
import org.dspace.app.rest.model.AuthorityRest;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.authority.Choice;
|
||||
import org.dspace.content.authority.Choices;
|
||||
import org.dspace.content.authority.ChoiceAuthority;
|
||||
import org.dspace.content.authority.service.ChoiceAuthorityService;
|
||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -36,104 +29,21 @@ public class AuthorityUtils {
|
||||
public static final String PRESENTATION_TYPE_LOOKUP = "lookup";
|
||||
|
||||
public static final String PRESENTATION_TYPE_SUGGEST = "suggest";
|
||||
|
||||
|
||||
public static final String RESERVED_KEYMAP_PARENT = "parent";
|
||||
|
||||
@Autowired
|
||||
private ChoiceAuthorityService cas;
|
||||
|
||||
public AuthorityRest getAuthority(String schema, String element, String qualifier) {
|
||||
return buildAuthorityRest(cas.getChoiceAuthorityName(schema, element, qualifier), schema, element, qualifier);
|
||||
}
|
||||
|
||||
public AuthorityRest getAuthority(String name) {
|
||||
String metadata = cas.getChoiceMetadatabyAuthorityName(name);
|
||||
if (StringUtils.isNotBlank(metadata)) {
|
||||
String[] tokens = tokenize(metadata);
|
||||
String schema = tokens[0];
|
||||
String element = tokens[1];
|
||||
String qualifier = tokens[2];
|
||||
return buildAuthorityRest(name, schema, element, qualifier);
|
||||
}
|
||||
return new AuthorityRest();
|
||||
}
|
||||
|
||||
private AuthorityRest buildAuthorityRest(String name, String schema, String element, String qualifier) {
|
||||
AuthorityRest authorityRest = new AuthorityRest();
|
||||
authorityRest.setName(name);
|
||||
authorityRest.setHierarchical(cas.isHierarchical(schema, element, qualifier));
|
||||
authorityRest.setScrollable(cas.isScrollable(schema, element, qualifier));
|
||||
authorityRest.setIdentifier(cas.hasIdentifier(schema, element, qualifier));
|
||||
return authorityRest;
|
||||
}
|
||||
|
||||
public List<AuthorityRest> getAuthorities() {
|
||||
Set<String> names = cas.getChoiceAuthoritiesNames();
|
||||
List<AuthorityRest> authorities = new ArrayList<AuthorityRest>();
|
||||
for (String name : names) {
|
||||
authorities.add(getAuthority(name));
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
||||
private String[] tokenize(String metadata) {
|
||||
String separator = metadata.contains("_") ? "_" : ".";
|
||||
StringTokenizer dcf = new StringTokenizer(metadata, separator);
|
||||
|
||||
String[] tokens = { "", "", "" };
|
||||
int i = 0;
|
||||
while (dcf.hasMoreTokens()) {
|
||||
tokens[i] = dcf.nextToken().trim();
|
||||
i++;
|
||||
}
|
||||
// Tokens contains:
|
||||
// schema = tokens[0];
|
||||
// element = tokens[1];
|
||||
// qualifier = tokens[2];
|
||||
return tokens;
|
||||
|
||||
}
|
||||
|
||||
private String standardize(String schema, String element, String qualifier, String separator) {
|
||||
if (StringUtils.isBlank(qualifier)) {
|
||||
return schema + separator + element;
|
||||
} else {
|
||||
return schema + separator + element + separator + qualifier;
|
||||
}
|
||||
}
|
||||
|
||||
public List<AuthorityEntryRest> query(String metadata, String query, Collection collection, int start, int limit,
|
||||
Locale locale) {
|
||||
List<AuthorityEntryRest> result = new ArrayList<AuthorityEntryRest>();
|
||||
if(StringUtils.isNotBlank(metadata)) {
|
||||
String[] tokens = tokenize(metadata);
|
||||
Choices choice = cas.getMatches(standardize(tokens[0], tokens[1], tokens[2], "_"), query, collection, start,
|
||||
limit, locale.toString());
|
||||
for (Choice value : choice.values) {
|
||||
AuthorityEntryRest rr = buildEntry(value);
|
||||
result.add(rr);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public AuthorityEntryRest get(String metadata, String authKey, String currentLocale) {
|
||||
Choice value = cas.getChoice(metadata, authKey, currentLocale);
|
||||
AuthorityEntryRest rr = buildEntry(value);
|
||||
return rr;
|
||||
}
|
||||
|
||||
private AuthorityEntryRest buildEntry(Choice value) {
|
||||
AuthorityEntryRest rr = new AuthorityEntryRest();
|
||||
rr.setId(value.authority);
|
||||
rr.setValue(value.value);
|
||||
rr.setDisplay(value.label);
|
||||
//TODO
|
||||
rr.setCount(0);
|
||||
rr.setOtherInformation(value.extras);
|
||||
return rr;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AuthorityEntryRestConverter entryConverter;
|
||||
|
||||
@Autowired
|
||||
private AuthorityRestConverter authorityConverter;
|
||||
|
||||
|
||||
public boolean isChoice(String schema, String element, String qualifier) {
|
||||
return cas.isChoicesConfigured(standardize(schema, element, qualifier, "_"));
|
||||
return cas.isChoicesConfigured(org.dspace.core.Utils.standardize(schema, element, qualifier, "_"));
|
||||
}
|
||||
|
||||
public String getAuthorityName(String schema, String element, String qualifier) {
|
||||
@@ -141,10 +51,36 @@ public class AuthorityUtils {
|
||||
}
|
||||
|
||||
public boolean isClosed(String schema, String element, String qualifier) {
|
||||
return cas.isClosed(standardize(schema, element, qualifier, "_"));
|
||||
return cas.isClosed(org.dspace.core.Utils.standardize(schema, element, qualifier, "_"));
|
||||
}
|
||||
|
||||
public String getPresentation(String schema, String element, String qualifier) {
|
||||
return cas.getPresentation(standardize(schema, element, qualifier, "_"));
|
||||
return cas.getPresentation(org.dspace.core.Utils.standardize(schema, element, qualifier, "_"));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO the authorityName MUST be a part of Choice model
|
||||
*
|
||||
* @param choice
|
||||
* @param authorityName
|
||||
* @return
|
||||
*/
|
||||
public AuthorityEntryRest convertEntry(Choice choice, String authorityName) {
|
||||
AuthorityEntryRest entry = entryConverter.convert(choice);
|
||||
entry.setAuthorityName(authorityName);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO the authorityName MUST be a part of ChoiceAuthority model
|
||||
*
|
||||
* @param source
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public AuthorityRest convertAuthority(ChoiceAuthority source, String authorityName) {
|
||||
AuthorityRest result = authorityConverter.convert(source);
|
||||
result.setName(authorityName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user