private void writeAttributes(PrintWriter out, MetadataElement element) { final MetadataAttribute[] attributes = element.getAttributes(); for (MetadataAttribute attribute : attributes) { out.print(createAttributeName(attribute) + "\t"); out.print(attribute.getData().getElemString() + "\t"); out.print(attribute.getUnit() + "\t"); out.print(attribute.getDescription() + "\t\n"); } final MetadataElement[] subElements = element.getElements(); for (MetadataElement subElement : subElements) { writeAttributes(out, subElement); } }
ExpectedMetadata(MetadataAttribute attribute) { final MetadataElement metadataRoot = attribute.getProduct().getMetadataRoot(); MetadataElement currentElement = attribute.getParentElement(); final MetadataAttribute[] attributes = currentElement.getAttributes(); int index = 0; for (MetadataAttribute attrib : attributes) {
/** * Copies all metadata elements and attributes of the source element to the target element. * The copied elements and attributes are deeply cloned. * * @param source the source element. * @param target the target element. * * @throws NullPointerException if the source or the target element is {@code null}. */ public static void copyMetadata(MetadataElement source, MetadataElement target) { Assert.notNull(source, "source"); Assert.notNull(target, "target"); for (final MetadataElement element : source.getElements()) { target.addElement(element.createDeepClone()); } for (final MetadataAttribute attribute : source.getAttributes()) { target.addAttribute(attribute.createDeepClone()); } }
public MetadataElement createDeepClone() { MetadataElement clone = new MetadataElement(getName()); clone.setDescription(getDescription()); MetadataAttribute[] attributes = getAttributes(); for (MetadataAttribute attribute : attributes) { clone.addAttribute(attribute.createDeepClone()); } MetadataElement[] elements = getElements(); for (MetadataElement element : elements) { clone.addElement(element.createDeepClone()); } return clone; }
private void addMetadataElements(final MetadataElement[] elementes, final Element mdElem) { //Übernommen if (elementes == null) { return; } Debug.assertNotNull(mdElem); for (MetadataElement element : elementes) { final Element newElem = new Element(DimapProductConstants.TAG_METADATA_ELEMENT); newElem.setAttribute(DimapProductConstants.ATTRIB_NAME, element.getName()); final String description = element.getDescription(); if (description != null) { newElem.setAttribute(DimapProductConstants.ATTRIB_DESCRIPTION, description); } addMetadataAttributes(element.getAttributes(), newElem); addMetadataElements(element.getElements(), newElem); mdElem.addContent(newElem); } }
protected void writeMetadataElements(int indent, final MetadataElement[] elementes) { if (elementes == null) { return; } for (final MetadataElement element : elementes) { String[][] attributes; final String description = element.getDescription(); if (description != null) { attributes = new String[2][]; attributes[1] = new String[]{DimapProductConstants.ATTRIB_DESCRIPTION, description}; } else { attributes = new String[1][]; } attributes[0] = new String[]{DimapProductConstants.ATTRIB_NAME, element.getName()}; final String[] meTags = createTags(indent, DimapProductConstants.TAG_METADATA_ELEMENT, attributes); if (element.getNumElements() == 0 && element.getNumAttributes() == 0) { printLine(meTags, null); } else { println(meTags[0]); writeMetadataAttributes(indent + 1, element.getAttributes()); writeMetadataElements(indent + 1, element.getElements()); println(meTags[1]); } } }
private void addBands(Product product, VirtualDir folder, String basePath) throws IOException { final GeoTiffProductReaderPlugIn plugIn = new GeoTiffProductReaderPlugIn(); final MetadataAttribute[] productAttributes = landsatMetadata.getProductMetadata().getAttributes(); final Pattern pattern = landsatMetadata.getOpticalBandFileNamePattern();
final MetadataElement propertyElement = metadataElements[0]; final MetadataElement recordElement = metadataElements[1]; final MetadataAttribute[] properties = propertyElement.getAttributes(); final MetadataElement[] records = recordElement.getElements(); assertEquals(3, firstRecord.getAttributes().length); assertEquals("station", firstRecord.getAttributes()[0].getName()); assertEquals("AMRU1", firstRecord.getAttributes()[0].getData().getElemString()); assertEquals(ProductData.UTC.parse("2010-06-01T12:45:00", Constants.TIME_PATTERN).getAsDate().getTime(), firstRecord.getAttributeUTC("date_time").getAsDate().getTime()); assertEquals(ProductData.UTC.parse("2011-06-01T10:45:00", Constants.TIME_PATTERN).getAsDate().getTime(), firstRecord.getAttributeUTC("testTime").getAsDate().getTime()); assertEquals(2, secondRecord.getAttributes().length); assertEquals("station", secondRecord.getAttributes()[0].getName()); assertEquals("AMRU1", secondRecord.getAttributes()[0].getData().getElemString()); assertEquals(ProductData.UTC.parse("2010-06-01T12:48:00", Constants.TIME_PATTERN).getAsDate().getTime(), secondRecord.getAttributeUTC("date_time").getAsDate().getTime()); assertNull(secondRecord.getAttribute("testTime")); assertEquals(2, thirdRecord.getAttributes().length); assertEquals("station", thirdRecord.getAttributes()[0].getName()); assertEquals("AMRU2", thirdRecord.getAttributes()[0].getData().getElemString()); assertNull(thirdRecord.getAttribute("date_time")); assertEquals(ProductData.UTC.parse("2011-06-01T12:45:00", Constants.TIME_PATTERN).getAsDate().getTime(), thirdRecord.getAttributeUTC("testTime").getAsDate().getTime());
final MetadataElement mosaicSourcesElement = getSourcesElement(mosaicOp, mosaicMetadata); assertEquals(2, mosaicSourcesElement.getNumAttributes()); for (int i = 0; i < mosaicSourcesElement.getAttributes().length; i++) { MetadataAttribute attribute = mosaicSourcesElement.getAttributes()[i]; assertEquals("sourceProduct." + (1 + i), attribute.getName()); final MetadataElement updateSourcesElement = getSourcesElement(mosaicUpdateOp, updateMetadata); assertEquals(3, updateSourcesElement.getNumAttributes()); for (int i = 0; i < updateSourcesElement.getAttributes().length; i++) { MetadataAttribute attribute = updateSourcesElement.getAttributes()[i]; assertEquals("sourceProduct." + (1 + i), attribute.getName());