@Override protected List<String> getURLs(Item item) { // Get all metadata elements that start with http:// or https:// List<MetadataValue> urls = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY); ArrayList<String> theURLs = new ArrayList<String>(); for (MetadataValue url : urls) { if ((url.getValue().startsWith("http://")) || (url.getValue().startsWith("https://"))) { theURLs.add(url.getValue()); } } return theURLs; } }
private void process(Context context, String metadata, MetadataValue current) { String key = mappingIdentifier.get(metadata); Set<String> identifiers = null; if (!results.containsKey(key)) { identifiers = new HashSet<String>(); } else { identifiers = results.get(key); } identifiers.add(current.getValue()); results.put(key, identifiers); }
@Override public String getAllMetadataSeparated(Item item, String metadataKey) { List<MetadataValue> dcValues = itemService.getMetadataByMetadataString(item, metadataKey); ArrayList<String> valueArray = new ArrayList<String>(); for (MetadataValue dcValue : dcValues) { if (StringUtils.isNotBlank(dcValue.getValue())) { valueArray.add(dcValue.getValue()); } } return StringUtils.join(valueArray.toArray(), "; "); }
@Override public String getMetadata(T dso, String value) { List<MetadataValue> metadataValues = getMetadataByMetadataString(dso, value); if (CollectionUtils.isNotEmpty(metadataValues)) { return metadataValues.iterator().next().getValue(); } return null; }
@Override public List<String> getISSNs(Context context, Item item) { List<String> values = new ArrayList<String>(); for (String metadata : metadataList) { List<MetadataValue> dcvalues = itemService.getMetadataByMetadataString(item, metadata); for (MetadataValue dcvalue : dcvalues) { values.add(dcvalue.getValue()); } } return values; } }
protected String getOneDC(Item item, String field) { List<MetadataValue> dcv = itemService.getMetadataByMetadataString(item, field); return (dcv.size() > 0) ? dcv.get(0).getValue() : null; } }
/** * Normalize the title of a Metadatum. * * @param value metadata value * @return normalized title */ protected String normalizeTitle(MetadataValue value) { if (!"title".equals(element)) { return value.getValue(); } return OrderFormat.makeSortString(value.getValue(), value.getLanguage(), OrderFormat.TITLE); } }
/** * If metadata field contains multiple values, then add each value to the map separately * * @param FIELD metadata field */ protected void addMultipleValues(String FIELD) { String fieldConfig = googleScholarSettings.get(FIELD); ArrayList<MetadataValue> fields = resolveMetadataFields(fieldConfig); if (null != fields && !fields.isEmpty()) { for (MetadataValue field : fields) { //TODO if this is author field, first-name first metadataMappings.put(FIELD, field.getValue()); } } }
/** * Get the URLs to check * * @param item The item to extract URLs from * @return An array of URL Strings */ protected List<String> getURLs(Item item) { // Get URIs from anyschema.anyelement.uri.* List<MetadataValue> urls = itemService.getMetadata(item, Item.ANY, Item.ANY, "uri", Item.ANY); ArrayList<String> theURLs = new ArrayList<String>(); for (MetadataValue url : urls) { theURLs.add(url.getValue()); } return theURLs; }
/** * Add the date of publication from the bibliographic metadata */ protected void addPublishDate() { List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, "dc.date.issued"); if (dcv != null && !dcv.isEmpty()) { entry.setPublished(dcv.get(0).getValue()); } }
protected DCDate recoverEmbargoDate(Item item) { DCDate liftDate = null; List<MetadataValue> lift = itemService.getMetadata(item, lift_schema, lift_element, lift_qualifier, Item.ANY); if (lift.size() > 0) { liftDate = new DCDate(lift.get(0).getValue()); // sanity check: do not allow an embargo lift date in the past. if (liftDate.toDate().before(new Date())) { liftDate = null; } } return liftDate; }
/** * Add all the subject classifications from the bibliographic * metadata. */ protected void addCategories() { List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, "dc.subject.*"); if (dcv != null) { for (MetadataValue aDcv : dcv) { entry.addCategory(aDcv.getValue()); } } }
/** * Add the date that this item was last updated */ protected void addLastUpdatedDate() { String config = ConfigurationManager .getProperty("sword-server", "updated.field"); List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, config); if (dcv != null && dcv.size() == 1) { DCDate dcd = new DCDate(dcv.get(0).getValue()); entry.setUpdated(dcd.toString()); } } }
@Override public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) { if (dso instanceof Item) { Item item = (Item) dso; List<MetadataValue> dcValues = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY); List<String> toIgnoreMetadataFields = SearchUtils.getIgnoredMetadataFields(item.getType()); for (MetadataValue dcValue : dcValues) { if (!toIgnoreMetadataFields.contains(dcValue.getMetadataField().toString('.'))) { document.addField("a_spell", dcValue.getValue()); } } } } }
/** * Add the summary/abstract from the bibliographic metadata */ protected void addSummary() { List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, "dc.description.abstract"); if (dcv != null) { for (MetadataValue aDcv : dcv) { Summary summary = new Summary(); summary.setContent(aDcv.getValue()); summary.setType(ContentType.TEXT); entry.setSummary(summary); } } }
/** * Add the title from the bibliographic metadata */ protected void addTitle() { List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, "dc.title"); if (dcv != null) { for (MetadataValue aDcv : dcv) { Title title = new Title(); title.setContent(aDcv.getValue()); title.setType(ContentType.TEXT); entry.setTitle(title); } } }
/** * Get display of Metadatum * * @param dcv MetadataValue * @return string displaying elements of the Metadatum */ public static String getDCValueString(MetadataValue dcv) { MetadataField metadataField = dcv.getMetadataField(); MetadataSchema metadataSchema = metadataField.getMetadataSchema(); return "schema: " + metadataSchema.getName() + "; element: " + metadataField .getElement() + "; qualifier: " + metadataField.getQualifier() + "; language: " + dcv.getLanguage() + "; value: " + dcv.getValue(); }
protected void copyMetadata(Context context, Item itemNew, Item nativeItem) throws SQLException { List<MetadataValue> md = itemService.getMetadata(nativeItem, Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (MetadataValue aMd : md) { MetadataField metadataField = aMd.getMetadataField(); MetadataSchema metadataSchema = metadataField.getMetadataSchema(); String unqualifiedMetadataField = metadataSchema.getName() + "." + metadataField.getElement(); if (getIgnoredMetadataFields().contains(metadataField.toString('.')) || getIgnoredMetadataFields().contains(unqualifiedMetadataField + "." + Item.ANY)) { //Skip this metadata field continue; } itemService .addMetadata(context, itemNew, metadataField, aMd.getLanguage(), aMd.getValue(), aMd.getAuthority(), aMd.getConfidence()); } }
public MockMetadataValue(MetadataValue metadataValue) { MetadataField metadataField = metadataValue.getMetadataField(); MetadataSchema metadataSchema = metadataField.getMetadataSchema(); schema = metadataSchema.getName(); element = metadataField.getElement(); qualifier = metadataField.getQualifier(); language = metadataValue.getLanguage(); value = metadataValue.getValue(); authority = metadataValue.getAuthority(); confidence = metadataValue.getConfidence(); }