/** * Converts format id from the DcsFormat objects into formatURI string with qualifying namespace. Only applicable * to pronom format identifier at this point. * @param dcsFormat * @return */ private String createFormatURIString(DcsFormat dcsFormat) { if (dcsFormat.getSchemeUri().equals(pronomSchemaUri)) { return "info:pronom/" + dcsFormat.getFormat(); } else { log.info("Format URI conversion is not supported for: " + dcsFormat.getSchemeUri() + ". Format URI conversion is supported for " + pronomSchemaUri + ". Returning format string as format URI"); return dcsFormat.getFormat(); } }
protected String extract_format(String value) { try { DcsFormat format = DcsFormat.parseDcsFormat(value); if (format.getSchemeUri() != null && format.getSchemeUri().equals(PRONOM_URI)) { return PRONOM_FORMAT_PREFIX + format.getFormat(); } else { return format.getFormat(); } } catch (IllegalArgumentException e) { return null; } }
/** * Copy constructor for a DcsFormat. The state of <code>toCopy</code> is copied * to this. * * @param toCopy the dcs format to copy */ public DcsFormat(DcsFormat toCopy) { this.format = toCopy.getFormat(); this.version = toCopy.getVersion(); this.name = toCopy.getName(); this.schemeUri = toCopy.getSchemeUri(); }
private Map<String, Integer> getFileCountByFormat(Set<AttributeSet> fileAttributeSets) { //TODO: map keyed by format's name. keyed by DcsFormat object would be more reliable. Report consumer can //decide what field of DcsFormat to use. But IngestReport doesn't current support mapping keyed on DcsFormat type. Map<String, Integer> fileCountByFormat = new HashMap<String, Integer>(); for (AttributeSet fileAttributeSet : fileAttributeSets) { //extract file-formats java.util.Collection<Attribute> matchingAttributes = fileAttributeSet.getAttributesByName(Metadata.FILE_FORMAT); for (Attribute attribute : matchingAttributes) { if (attribute.getType().equals(AttributeValueType.DCS_FORMAT)) { DcsFormat format = DcsFormat.parseDcsFormat(attribute.getValue()); // Only add the Pronom format to the report to be displayed or the unknown mime-type // (application/octet-stream) if (format.getSchemeUri().contains("PRONOM") || format.getName().equalsIgnoreCase("application/octet-stream")) { // if an entry for this format does not exist yet if (!fileCountByFormat.containsKey(format.getName())) { // create the new entry fileCountByFormat.put(format.getName(), 0); } // increase count for the format entry. fileCountByFormat.put(format.getName(), fileCountByFormat.get(format.getName()) + 1); } } } } return fileCountByFormat; } /**
private static void addFormatSet(SolrInputDocument doc, Collection<DcsFormat> set) { if (set == null || set.size() == 0) { return; } for (DcsFormat fmt : set) { setadd(doc, FormatField.NAME, fmt.getName()); setadd(doc, FormatField.FORMAT, fmt.getFormat()); setadd(doc, FormatField.SCHEMA, fmt.getSchemeUri()); setadd(doc, FormatField.VERSION, fmt.getVersion()); } }
event.setOutcome(format.getSchemeUri() + " " + format.getFormat()); DcsEntityReference ref = new DcsEntityReference(file.getPath()); List<DcsEntityReference> refs = new ArrayList<DcsEntityReference>();
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { super.marshal(source, writer, context); final DcsFormat format = (DcsFormat) source; writer.startNode(E_ID); if (format.getSchemeUri() != null) { writer.addAttribute(A_SCHEME, format.getSchemeUri()); } if (format.getFormat() != null) { writer.setValue(format.getFormat()); } writer.endNode(); if (format.getName() != null) { writer.startNode(E_NAME); writer.setValue(format.getName()); writer.endNode(); } if (format.getVersion() != null) { writer.startNode(E_VERSION); writer.setValue(format.getVersion()); writer.endNode(); } }
@Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { super.marshal(source, writer, context); final DcsFormat format = (DcsFormat) source; writer.startNode(E_ID); if (format.getSchemeUri() != null) { writer.addAttribute(A_SCHEME, format.getSchemeUri()); } if (format.getFormat() != null) { writer.setValue(format.getFormat()); } writer.endNode(); if (format.getName() != null) { writer.startNode(E_NAME); writer.setValue(format.getName()); writer.endNode(); } if (format.getVersion() != null) { writer.startNode(E_VERSION); writer.setValue(format.getVersion()); writer.endNode(); } }
if (formatEntry.getSchemeUri().equals(ianaURI)) { fileMIME = formatEntry.getFormat(); if (formatEntry.getSchemeUri().equals(registryURI)) { fileFormatURI = formatEntry.getFormat();