private Set<DcsMetadataRef> createMetadataRefSet(int size) { Set<DcsMetadataRef> result = new HashSet<DcsMetadataRef>(); for (int i = 0; i < size; i++) { DcsMetadataRef ref = new DcsMetadataRef(); ref.setRef(randomString(10, false)); result.add(ref); } return result; }
private static Set<DcsMetadataRef> getMetadataRefSet(SolrDocument doc, SolrName field) { Set<DcsMetadataRef> set = new HashSet<DcsMetadataRef>(); for (String s : setgetAll(doc, field)) { DcsMetadataRef ref = new DcsMetadataRef(); if (s != null) { ref.setRef(s); } set.add(ref); } return set; }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { final String schemaUri = reader.getAttribute(A_SCHEMA); final String mdRef = reader.getAttribute(A_REF); // If we are dealing with a reference, create the reference and return if (!isEmptyOrNull(mdRef)) { final DcsMetadataRef ref = new DcsMetadataRef(); ref.setRef(mdRef); return ref; } // Otherwise we're dealing with a full, in-line DcsMetadata object final DcsMetadata md = new DcsMetadata(); if (!isEmptyOrNull(schemaUri)) { md.setSchemaUri(schemaUri); } final ByteArrayOutputStream out = new ByteArrayOutputStream(); reader.moveDown(); try { ((DcsStaxReader) reader.underlyingReader()).copyNode(out); } catch (XMLStreamException e) { throw new ConversionException(e.getMessage(), e); } reader.moveUp(); final String mdValue = new String(out.toByteArray(), Charset.forName("UTF-8")); md.setMetadata(mdValue); log.trace("Deserialized metadata blob \n{}", mdValue); return md; }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { final String schemaUri = reader.getAttribute(A_SCHEMA); final String mdRef = reader.getAttribute(A_REF); // If we are dealing with a reference, create the reference and return if (!isEmptyOrNull(mdRef)) { final DcsMetadataRef ref = new DcsMetadataRef(); ref.setRef(mdRef); return ref; } // Otherwise we're dealing with a full, in-line DcsMetadata object final DcsMetadata md = new DcsMetadata(); if (!isEmptyOrNull(schemaUri)) { md.setSchemaUri(schemaUri); } final ByteArrayOutputStream out = new ByteArrayOutputStream(); reader.moveDown(); try { ((DcsStaxReader) reader.underlyingReader()).copyNode(out); } catch (XMLStreamException e) { throw new RuntimeException("Unmarshalling failed", e); } reader.moveUp(); final String metadataAsString = new String(out.toByteArray(), Charset.forName("UTF-8")); md.setMetadata(metadataAsString); return md; }
@Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { final String schemaUri = reader.getAttribute(A_SCHEMA); final String mdRef = reader.getAttribute(A_REF); // If we are dealing with a reference, create the reference and return if (!isEmptyOrNull(mdRef)) { final DcsMetadataRef ref = new DcsMetadataRef(); ref.setRef(mdRef); return ref; } // Otherwise we're dealing with a full, in-line DcsMetadata object final DcsMetadata md = new DcsMetadata(); if (!isEmptyOrNull(schemaUri)) { md.setSchemaUri(schemaUri); } final ByteArrayOutputStream out = new ByteArrayOutputStream(); reader.moveDown(); try { ((DcsStaxReader) reader.underlyingReader()).copyNode(out); } catch (XMLStreamException e) { throw new ConversionException(e.getMessage(), e); } reader.moveUp(); final String mdValue = new String(out.toByteArray(), Charset.forName("UTF-8")); md.setMetadata(mdValue); log.trace("Deserialized metadata blob \n{}", mdValue); return md; }