use of org.opengis.metadata.identification.Identification in project tika by apache.
the class GeographicInformationParser method extractContent.
private void extractContent(XHTMLContentHandler xhtmlContentHandler, DefaultMetadata defaultMetadata) throws SAXException {
xhtmlContentHandler.startDocument();
xhtmlContentHandler.newline();
xhtmlContentHandler.newline();
ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetadata.getIdentificationInfo();
for (Identification i : identifications) {
xhtmlContentHandler.startElement("h1");
xhtmlContentHandler.characters(i.getCitation().getTitle().toString());
xhtmlContentHandler.endElement("h1");
xhtmlContentHandler.newline();
ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
for (ResponsibleParty r : responsiblePartyArrayList) {
xhtmlContentHandler.startElement("h3");
xhtmlContentHandler.newline();
xhtmlContentHandler.characters("CitedResponsiblePartyRole " + r.getRole().toString());
xhtmlContentHandler.characters("CitedResponsiblePartyName " + r.getIndividualName().toString());
xhtmlContentHandler.endElement("h3");
xhtmlContentHandler.newline();
}
xhtmlContentHandler.startElement("p");
xhtmlContentHandler.newline();
xhtmlContentHandler.characters("IdentificationInfoAbstract " + i.getAbstract().toString());
xhtmlContentHandler.endElement("p");
xhtmlContentHandler.newline();
Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
for (Extent e : extentList) {
ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
for (GeographicExtent g : geoElements) {
if (g instanceof DefaultGeographicBoundingBox) {
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementWestBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getWestBoundLongitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementEastBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getEastBoundLongitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementNorthBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getNorthBoundLatitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
xhtmlContentHandler.startElement("tr");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters("GeographicElementSouthBoundLatitude");
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.startElement("td");
xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getSouthBoundLatitude()));
xhtmlContentHandler.endElement("td");
xhtmlContentHandler.endElement("tr");
}
}
}
}
xhtmlContentHandler.newline();
xhtmlContentHandler.endDocument();
}
use of org.opengis.metadata.identification.Identification in project sis by apache.
the class XLinkMarshallingTest method verify.
/**
* Verifies if the given metadata contains the expected {@code xlink:href} attribute value.
*
* @param isNilExpected {@code true} if the identification info is expected to be a {@link NilObject} instance.
* @param metadata the metadata to verify.
*/
private static void verify(final boolean isNilExpected, final DefaultMetadata metadata) {
final Identification identification = getSingleton(metadata.getIdentificationInfo());
assertEquals("NilObject", isNilExpected, identification instanceof NilObject);
assertInstanceOf("Identification", IdentifiedObject.class, identification);
final XLink xlink = ((IdentifiedObject) identification).getIdentifierMap().getSpecialized(IdentifierSpace.XLINK);
assertEquals("xlink:href", "http://test.net", xlink.getHRef().toString());
}
use of org.opengis.metadata.identification.Identification in project sis by apache.
the class StoreTest method verifyContent.
/**
* Verifies that the given metadata contains one of the given identifiers.
* The identifiers that are found are removed from the given set.
*/
private static void verifyContent(final Aggregate store, final Set<String> identifiers) throws DataStoreException {
for (final Resource resource : store.components()) {
assertNotNull("resource", resource);
for (Identification info : resource.getMetadata().getIdentificationInfo()) {
final String id = Citations.getIdentifier(info.getCitation());
assertTrue(id, identifiers.remove(id));
if (resource instanceof Aggregate) {
verifyContent((Aggregate) resource, identifiers);
}
}
}
}
use of org.opengis.metadata.identification.Identification in project sis by apache.
the class DefaultMetadata method setDataSetUri.
/**
* Sets the URI of the dataset to which the metadata applies.
* This method sets the linkage of the first online resource in the citation of the first identification info.
*
* @param newValue the new data set URI.
* @throws URISyntaxException if the given value can not be parsed as a URI.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getIdentificationInfo()}
* followed by {@link DefaultDataIdentification#getCitation()}
* followed by {@link DefaultCitation#setOnlineResources(Collection)}.
*/
@Deprecated
public void setDataSetUri(final String newValue) throws URISyntaxException {
final URI uri = new URI(newValue);
checkWritePermission();
// See "Note about deprecated methods implementation"
Collection<Identification> info = identificationInfo;
AbstractIdentification firstId = AbstractIdentification.castOrCopy(CollectionsExt.first(info));
if (firstId == null) {
firstId = new DefaultDataIdentification();
}
DefaultCitation citation = DefaultCitation.castOrCopy(firstId.getCitation());
if (citation == null) {
citation = new DefaultCitation();
}
Collection<OnlineResource> onlineResources = citation.getOnlineResources();
DefaultOnlineResource firstOnline = DefaultOnlineResource.castOrCopy(CollectionsExt.first(onlineResources));
if (firstOnline == null) {
firstOnline = new DefaultOnlineResource();
}
firstOnline.setLinkage(uri);
onlineResources = OtherLocales.setFirst(onlineResources, firstOnline);
citation.setOnlineResources(onlineResources);
firstId.setCitation(citation);
info = OtherLocales.setFirst(info, firstId);
setIdentificationInfo(info);
}
use of org.opengis.metadata.identification.Identification in project sis by apache.
the class DefaultMetadata method getDataSetUri.
/**
* Provides the URI of the dataset to which the metadata applies.
*
* @return Uniform Resource Identifier of the dataset, or {@code null}.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #getIdentificationInfo()} followed by
* {@link DefaultDataIdentification#getCitation()} followed by {@link DefaultCitation#getOnlineResources()}.
*/
@Override
@Deprecated
@Dependencies("getIdentificationInfo")
@XmlElement(name = "dataSetURI", namespace = LegacyNamespaces.GMD)
public String getDataSetUri() {
String linkage = null;
final Collection<Identification> info;
if (FilterByVersion.LEGACY_METADATA.accept() && (info = getIdentificationInfo()) != null) {
for (final Identification identification : info) {
final Citation citation = identification.getCitation();
if (citation instanceof DefaultCitation) {
final Collection<? extends OnlineResource> onlineResources = ((DefaultCitation) citation).getOnlineResources();
if (onlineResources != null) {
for (final OnlineResource link : onlineResources) {
final URI uri = link.getLinkage();
if (uri != null) {
if (linkage == null) {
linkage = uri.toString();
} else {
LegacyPropertyAdapter.warnIgnoredExtraneous(OnlineResource.class, DefaultMetadata.class, "getDataSetUri");
break;
}
}
}
}
}
}
}
return linkage;
}
Aggregations