mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
[DS-3699] manage valuepairs and vocabulary authority both controlled and required configuration setup to true
This commit is contained in:
@@ -14,9 +14,12 @@ import java.util.Map;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
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.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||||
import org.dspace.content.service.MetadataFieldService;
|
import org.dspace.content.service.MetadataFieldService;
|
||||||
@@ -142,6 +145,8 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService
|
|||||||
{
|
{
|
||||||
defaultMinConfidence = dmc;
|
defaultMinConfidence = dmc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
autoRegisterAuthorityFromInputReader();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,4 +242,31 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService
|
|||||||
}
|
}
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void autoRegisterAuthorityFromInputReader() {
|
||||||
|
try {
|
||||||
|
DCInputsReader dcInputsReader = new DCInputsReader();
|
||||||
|
for (DCInputSet dcinputSet : dcInputsReader.getAllInputs(Integer.MAX_VALUE, 0)) {
|
||||||
|
DCInput[] dcinputs = dcinputSet.getFields();
|
||||||
|
for (DCInput dcinput : dcinputs) {
|
||||||
|
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());
|
||||||
|
controlled.put(fieldKey, true);
|
||||||
|
isAuthorityRequired.put(fieldKey, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DCInputsReaderException e) {
|
||||||
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -359,8 +359,8 @@ public class ItemTest extends AbstractDSpaceObjectTest
|
|||||||
// Set the item to have two pieces of metadata for dc.type and dc2.type
|
// Set the item to have two pieces of metadata for dc.type and dc2.type
|
||||||
String dcType = "DC-TYPE";
|
String dcType = "DC-TYPE";
|
||||||
String testType = "TEST-TYPE";
|
String testType = "TEST-TYPE";
|
||||||
itemService.addMetadata(context, it, "dc", "type", null, null, dcType);
|
itemService.addMetadata(context, it, "dc", "type", null, null, dcType, "accepted", 0);
|
||||||
itemService.addMetadata(context, it, "test", "type", null, null, testType);
|
itemService.addMetadata(context, it, "test", "type", null, null, testType, "accepted", 0);
|
||||||
|
|
||||||
// Check that only one is returned when we ask for all dc.type values
|
// Check that only one is returned when we ask for all dc.type values
|
||||||
List<MetadataValue> values = itemService.getMetadata(it, "dc", "type", null, null);
|
List<MetadataValue> values = itemService.getMetadata(it, "dc", "type", null, null);
|
||||||
|
Reference in New Issue
Block a user