use of org.opengis.metadata.distribution.Format in project sis by apache.
the class CustomMetadataTest method testSubtypeAttributes.
/**
* Tests that the attributes defined in subtypes are also marshalled.
*
* @throws JAXBException if an error occurred during (un)marshalling.
*
* @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
*/
@Test
public void testSubtypeAttributes() throws JAXBException {
final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
final DataIdentification identification = new DataIdentification() {
@Override
public InternationalString getAbstract() {
Map<Locale, String> names = new HashMap<>();
names.put(Locale.ENGLISH, "Description");
return factory.createInternationalString(names);
}
@Override
public InternationalString getEnvironmentDescription() {
Map<Locale, String> names = new HashMap<>();
names.put(Locale.ENGLISH, "Environment");
return factory.createInternationalString(names);
}
@Override
public InternationalString getSupplementalInformation() {
return null;
}
@Override
public Citation getCitation() {
return null;
}
@Override
public InternationalString getPurpose() {
return null;
}
@Override
public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
return null;
}
@Override
public Collection<Resolution> getSpatialResolutions() {
return null;
}
@Override
public Collection<Locale> getLanguages() {
return null;
}
@Override
public Collection<CharacterSet> getCharacterSets() {
return null;
}
@Override
public Collection<TopicCategory> getTopicCategories() {
return null;
}
@Override
public Collection<Extent> getExtents() {
return null;
}
@Override
public Collection<String> getCredits() {
return null;
}
@Override
public Collection<Progress> getStatus() {
return null;
}
@Override
public Collection<ResponsibleParty> getPointOfContacts() {
return null;
}
@Override
public Collection<MaintenanceInformation> getResourceMaintenances() {
return null;
}
@Override
public Collection<BrowseGraphic> getGraphicOverviews() {
return null;
}
@Override
public Collection<Format> getResourceFormats() {
return null;
}
@Override
public Collection<Keywords> getDescriptiveKeywords() {
return null;
}
@Override
public Collection<Usage> getResourceSpecificUsages() {
return null;
}
@Override
public Collection<Constraints> getResourceConstraints() {
return null;
}
@Deprecated
@Override
public Collection<AggregateInformation> getAggregationInfo() {
return null;
}
};
final DefaultMetadata data = new DefaultMetadata();
data.setIdentificationInfo(singleton(identification));
final String xml = XML.marshal(data);
/*
* A few simple checks.
*/
assertTrue("Missing Identification attribute.", xml.contains("Description"));
assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
use of org.opengis.metadata.distribution.Format in project sis by apache.
the class Store method getFormat.
/**
* Returns a more complete description of the GPX format.
* The format will be part of the metadata returned by {@link #getMetadata()}.
*
* @see StoreProvider#getFormat()
* @see org.apache.sis.internal.storage.gpx.Metadata#getResourceFormats()
*/
final Format getFormat() {
assert Thread.holdsLock(this);
Format format = ((StoreProvider) provider).getFormat(listeners);
if (version != null) {
final DefaultFormat df = new DefaultFormat(format);
final DefaultCitation citation = new DefaultCitation(df.getFormatSpecificationCitation());
citation.setEdition(new SimpleInternationalString(version.toString()));
df.setFormatSpecificationCitation(citation);
format = df;
}
return format;
}
use of org.opengis.metadata.distribution.Format in project tika by apache.
the class GeographicInformationParser method getMetaDataDistributionInfo.
private void getMetaDataDistributionInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
Distribution distribution = defaultMetaData.getDistributionInfo();
ArrayList<Format> distributionFormat = (ArrayList<Format>) distribution.getDistributionFormats();
for (Format f : distributionFormat) {
if (f.getName() != null)
metadata.add("DistributionFormatSpecificationAlternativeTitle ", f.getName().toString());
}
ArrayList<Distributor> distributorList = (ArrayList<Distributor>) distribution.getDistributors();
for (Distributor d : distributorList) {
if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getRole() != null)
metadata.add("Distributor Contact ", d.getDistributorContact().getRole().name());
if (d != null && d.getDistributorContact() != null && d.getDistributorContact().getOrganisationName() != null)
metadata.add("Distributor Organization Name ", d.getDistributorContact().getOrganisationName().toString());
}
ArrayList<DigitalTransferOptions> transferOptionsList = (ArrayList<DigitalTransferOptions>) distribution.getTransferOptions();
for (DigitalTransferOptions d : transferOptionsList) {
ArrayList<OnlineResource> onlineResourceList = (ArrayList<OnlineResource>) d.getOnLines();
for (OnlineResource or : onlineResourceList) {
if (or.getLinkage() != null)
metadata.add("TransferOptionsOnlineLinkage ", or.getLinkage().toString());
if (or.getProtocol() != null)
metadata.add("TransferOptionsOnlineProtocol ", or.getProtocol());
if (or.getApplicationProfile() != null)
metadata.add("TransferOptionsOnlineProfile ", or.getApplicationProfile());
if (or.getName() != null)
metadata.add("TransferOptionsOnlineName ", or.getName());
if (or.getDescription() != null)
metadata.add("TransferOptionsOnlineDescription ", or.getDescription().toString());
if (or.getFunction() != null)
metadata.add("TransferOptionsOnlineFunction ", or.getFunction().name());
}
}
}
use of org.opengis.metadata.distribution.Format in project tika by apache.
the class GeographicInformationParser method getMetaDataIdentificationInfo.
private void getMetaDataIdentificationInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetaData.getIdentificationInfo();
for (Identification i : identifications) {
DefaultDataIdentification defaultDataIdentification = (DefaultDataIdentification) i;
if (i.getCitation() != null && i.getCitation().getTitle() != null)
metadata.add("IdentificationInfoCitationTitle ", i.getCitation().getTitle().toString());
ArrayList<CitationDate> dateArrayList = (ArrayList<CitationDate>) i.getCitation().getDates();
for (CitationDate d : dateArrayList) {
if (d.getDateType() != null)
metadata.add("CitationDate ", d.getDateType().name() + "-->" + d.getDate());
}
ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
for (ResponsibleParty r : responsiblePartyArrayList) {
if (r.getRole() != null)
metadata.add("CitedResponsiblePartyRole ", r.getRole().toString());
if (r.getIndividualName() != null)
metadata.add("CitedResponsiblePartyName ", r.getIndividualName().toString());
if (r.getOrganisationName() != null)
metadata.add("CitedResponsiblePartyOrganizationName ", r.getOrganisationName().toString());
if (r.getPositionName() != null)
metadata.add("CitedResponsiblePartyPositionName ", r.getPositionName().toString());
if (r.getContactInfo() != null) {
for (String s : r.getContactInfo().getAddress().getElectronicMailAddresses()) {
metadata.add("CitedResponsiblePartyEMail ", s.toString());
}
}
}
if (i.getAbstract() != null)
metadata.add("IdentificationInfoAbstract ", i.getAbstract().toString());
for (Progress p : i.getStatus()) {
metadata.add("IdentificationInfoStatus ", p.name());
}
ArrayList<Format> formatArrayList = (ArrayList<Format>) i.getResourceFormats();
for (Format f : formatArrayList) {
if (f.getName() != null)
metadata.add("ResourceFormatSpecificationAlternativeTitle ", f.getName().toString());
}
CheckedHashSet<Locale> localeCheckedHashSet = (CheckedHashSet<Locale>) defaultDataIdentification.getLanguages();
for (Locale l : localeCheckedHashSet) {
metadata.add("IdentificationInfoLanguage-->", l.getDisplayLanguage(Locale.ENGLISH));
}
CodeListSet<TopicCategory> categoryList = (CodeListSet<TopicCategory>) defaultDataIdentification.getTopicCategories();
for (TopicCategory t : categoryList) {
metadata.add("IdentificationInfoTopicCategory-->", t.name());
}
ArrayList<Keywords> keywordList = (ArrayList<Keywords>) i.getDescriptiveKeywords();
int j = 1;
for (Keywords k : keywordList) {
j++;
ArrayList<InternationalString> stringList = (ArrayList<InternationalString>) k.getKeywords();
for (InternationalString s : stringList) {
metadata.add("Keywords " + j, s.toString());
}
if (k.getType() != null)
metadata.add("KeywordsType " + j, k.getType().name());
if (k.getThesaurusName() != null && k.getThesaurusName().getTitle() != null)
metadata.add("ThesaurusNameTitle " + j, k.getThesaurusName().getTitle().toString());
if (k.getThesaurusName() != null && k.getThesaurusName().getAlternateTitles() != null)
metadata.add("ThesaurusNameAlternativeTitle " + j, k.getThesaurusName().getAlternateTitles().toString());
ArrayList<CitationDate> citationDates = (ArrayList<CitationDate>) k.getThesaurusName().getDates();
for (CitationDate cd : citationDates) {
if (cd.getDateType() != null)
metadata.add("ThesaurusNameDate ", cd.getDateType().name() + "-->" + cd.getDate());
}
}
ArrayList<DefaultLegalConstraints> constraintList = (ArrayList<DefaultLegalConstraints>) i.getResourceConstraints();
for (DefaultLegalConstraints c : constraintList) {
for (Restriction r : c.getAccessConstraints()) {
metadata.add("AccessContraints ", r.name());
}
for (InternationalString s : c.getOtherConstraints()) {
metadata.add("OtherConstraints ", s.toString());
}
for (Restriction r : c.getUseConstraints()) {
metadata.add("UserConstraints ", r.name());
}
}
Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
for (Extent e : extentList) {
ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
for (GeographicExtent g : geoElements) {
if (g instanceof DefaultGeographicDescription) {
if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode() != null)
metadata.add("GeographicIdentifierCode ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode().toString());
if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle() != null)
metadata.add("GeographicIdentifierAuthorityTitle ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle().toString());
for (InternationalString s : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getAlternateTitles()) {
metadata.add("GeographicIdentifierAuthorityAlternativeTitle ", s.toString());
}
for (CitationDate cd : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getDates()) {
if (cd.getDateType() != null && cd.getDate() != null)
metadata.add("GeographicIdentifierAuthorityDate ", cd.getDateType().name() + " " + cd.getDate().toString());
}
}
}
}
}
}
use of org.opengis.metadata.distribution.Format in project sis by apache.
the class DocumentedStoreProvider method getFormat.
/**
* Returns a more complete description of the format, sending warnings to the given listeners if non-null.
*
* @param listeners where to report the warning in case of error, or {@code null} if none.
* @return a description of the data format.
*/
public final Format getFormat(final WarningListeners<DataStore> listeners) {
/*
* Note: this method does not cache the format because such caching is already done by MetadataSource.
*/
if (name != null)
try {
return MetadataSource.getProvided().lookup(Format.class, name);
} catch (MetadataStoreException e) {
if (listeners != null) {
listeners.warning(null, e);
} else {
final Level level;
if (!logged) {
// Not atomic - not a big deal if we use warning level twice.
logged = true;
level = Level.WARNING;
} else {
level = Level.FINE;
}
final LogRecord record = Resources.forLocale(null).getLogRecord(level, Resources.Keys.CanNotGetCommonMetadata_2, getShortName(), e.getLocalizedMessage());
record.setLoggerName(Modules.STORAGE);
Logging.log(getClass(), "getFormat", record);
}
}
return super.getFormat();
}
Aggregations