use of org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints in project sis by apache.
the class MetadataBuilderTest method verifyCopyrightParsing.
/**
* Verifies the metadata that contains the result of parsing a copyright statement.
* Should contains the "John Smith" name and 1992 year.
*
* @param notice the copyright statement to parse.
*/
private static void verifyCopyrightParsing(final String notice) {
final MetadataBuilder builder = new MetadataBuilder();
builder.parseLegalNotice(notice);
final DefaultLegalConstraints constraints = (DefaultLegalConstraints) getSingleton(getSingleton(builder.build(false).getIdentificationInfo()).getResourceConstraints());
assertEquals("useConstraints", Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints()));
final Citation ref = getSingleton(constraints.getReferences());
assertTitleEquals("reference.title", notice, ref);
assertPartyNameEquals("reference.citedResponsibleParty", "John Smith", (DefaultCitation) ref);
assertEquals("date", date("1992-01-01 00:00:00"), getSingleton(ref.getDates()).getDate());
}
use of org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints in project sis by apache.
the class FrenchProfileTest method testConstraintsToAFNOR.
/**
* Tests {@link FrenchProfile#toAFNOR(Object)} with {@link Constraints},
* {@link LegalConstraints} and {@link SecurityConstraints} objects.
*/
@Test
public void testConstraintsToAFNOR() {
Constraints std, fra;
std = new DefaultConstraints("Some constraints.");
fra = (Constraints) FrenchProfile.toAFNOR(std);
assertNotSame("Expected a copy.", std, fra);
assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
assertEquals("Some constraints.", getSingleton(fra.getUseLimitations()).toString());
std = new DefaultLegalConstraints("Some legal constraints.");
fra = (LegalConstraints) FrenchProfile.toAFNOR(std);
assertNotSame("Expected a copy.", std, fra);
assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
assertEquals("Some legal constraints.", getSingleton(fra.getUseLimitations()).toString());
std = new DefaultSecurityConstraints("Some security constraints.");
fra = (SecurityConstraints) FrenchProfile.toAFNOR(std);
assertNotSame("Expected a copy.", std, fra);
assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
assertEquals("Some security constraints.", getSingleton(fra.getUseLimitations()).toString());
}
use of org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints 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());
}
}
}
}
}
}
Aggregations