本文整理汇总了Java中org.gbif.api.vocabulary.ContactType类的典型用法代码示例。如果您正苦于以下问题:Java ContactType类的具体用法?Java ContactType怎么用?Java ContactType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContactType类属于org.gbif.api.vocabulary包,在下文中一共展示了ContactType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContact
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
/**
* Creates a contact using the parameters.
*/
protected static Contact createContact(
String firstName,
String lastName,
String email,
ContactType type,
boolean preferred
) {
Contact contact = new Contact();
contact.setEmail(Lists.newArrayList(email));
contact.setFirstName(firstName);
contact.setLastName(lastName);
contact.setType(type);
contact.setPrimary(preferred);
return contact;
}
示例2: getContentProviderContact
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
/**
* Checks the contacts of a dataset and finds the preferred contact that should be used as the main author
* of a dataset.
*
* @return preferred author contact or null
*/
public static Contact getContentProviderContact(Dataset dataset) {
Contact author = findFirstAuthor(dataset);
if (author != null) {
Contact provider = new Contact();
try {
PropertyUtils.copyProperties(provider, author);
provider.setKey(null);
provider.setType(ContactType.CONTENT_PROVIDER);
provider.setPrimary(false);
return provider;
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
LOG.error("Error setting provider contact", e);
}
}
return author;
}
示例3: testParseContactType
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testParseContactType() throws Exception {
assertEquals(ContactType.AUTHOR, VocabularyUtils.parseContactType("author"));
assertEquals(ContactType.ADMINISTRATIVE_POINT_OF_CONTACT,
VocabularyUtils.parseContactType("ADMINISTRATIVE POINT_of_CONTACT"));
VocabularyUtils.parseContactType("bad");
}
示例4: testLookupUsingOptional
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
@Test
public void testLookupUsingOptional() {
assertEquals(ContactType.AUTHOR, VocabularyUtils.lookup("author", ContactType.class).get());
//Optional.absent() should be returned for all the following values
assertEquals(Optional.absent(), VocabularyUtils.lookup("thor", ContactType.class));
assertEquals(Optional.absent(), VocabularyUtils.lookup("", ContactType.class));
assertEquals(Optional.absent(), VocabularyUtils.lookup(null, ContactType.class));
}
示例5: getType
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
@Nullable
public ContactType getType() {
return type;
}
示例6: setType
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
public void setType(ContactType type) {
this.type = type;
}
示例7: parseContactType
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
public static ContactType parseContactType(String type) {
return (ContactType) lookupEnum(type, ContactType.class);
}
示例8: generateMetadata
import org.gbif.api.vocabulary.ContactType; //导入依赖的package包/类
/**
* Creates a single EML metadata file for the entire archive.
* Make sure we execute this method AFTER building the constituents metadata which adds to our dataset instance.
*/
private void generateMetadata() {
LOG.info("Add query dataset metadata to archive");
try {
// Random UUID use because the downloadKey is not a string in UUID format
Download download = occurrenceDownloadService.get(configuration.getDownloadKey());
String downloadUniqueID = configuration.getDownloadKey();
if (download.getDoi() != null) {
downloadUniqueID = download.getDoi().getDoiName();
dataset.setDoi(download.getDoi());
Identifier identifier = new Identifier();
identifier.setCreated(download.getCreated());
identifier.setIdentifier(configuration.getDownloadKey());
identifier.setType(IdentifierType.GBIF_PORTAL);
dataset.setIdentifiers(Lists.newArrayList(identifier));
}
dataset.setKey(UUID.randomUUID());
dataset.setTitle(String.format(DATASET_TITLE_FMT, downloadUniqueID));
dataset.setDescription(getDatasetDescription());
dataset.setCreated(download.getCreated());
Citation citation = new Citation(String.format(DATASET_TITLE_FMT, downloadUniqueID), downloadUniqueID);
dataset.setCitation(citation);
// can we derive a link from the query to set the dataset.homepage?
dataset.setPubDate(download.getCreated());
dataset.setDataLanguage(Language.ENGLISH);
dataset.setType(DatasetType.OCCURRENCE);
dataset.getDataDescriptions().add(createDataDescription());
//TODO: use new license field once available
if (download.getLicense().isConcrete()) {
dataset.setRights(String.format(RIGHTS, download.getLicense().getLicenseTitle(), download.getLicense().getLicenseUrl()));
}
dataset.getContacts()
.add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
DOWNLOAD_CONTACT_EMAIL,
ContactType.ORIGINATOR,
true));
dataset.getContacts()
.add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
DOWNLOAD_CONTACT_EMAIL,
ContactType.ADMINISTRATIVE_POINT_OF_CONTACT,
true));
dataset.getContacts()
.add(DwcaContactsUtil.createContact(DOWNLOAD_CONTACT_SERVICE,
DOWNLOAD_CONTACT_EMAIL,
ContactType.METADATA_AUTHOR,
true));
File eml = new File(archiveDir, METADATA_FILENAME);
Writer writer = FileUtils.startNewUtf8File(eml);
EML_WRITER.writeTo(dataset, writer);
} catch (Exception e) {
LOG.error("Failed to write query result dataset EML file", e);
}
}