本文整理汇总了Java中org.gbif.ecat.voc.Rank类的典型用法代码示例。如果您正苦于以下问题:Java Rank类的具体用法?Java Rank怎么用?Java Rank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rank类属于org.gbif.ecat.voc包,在下文中一共展示了Rank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: abbreviateRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
/**
*
* @param rank
* Set the rank
* @return the abbreviated rank
*/
public static String abbreviateRank(Rank rank) {
if (rank == null) {
return null;
} else {
switch (rank) {
case VARIETY:
return "var";
case InfraspecificName:
return "infrasp";
case SUBSPECIES:
return "ssp";
case SPECIES:
return "sp";
case GENUS:
return "gen";
case Subtribe:
return "subtrib";
case Tribe:
return "trib";
case Subfamily:
return "subfam";
case FAMILY:
return "fam";
default:
return Rank.toAbbreviation(rank);
}
}
}
示例2: formatRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
/**
*
* @param rank
* Set the rank
* @return the formatted rank
*/
public static String formatRank(Rank rank) {
if (rank == null) {
return null;
} else {
String r = rank.name();
return r.substring(0, 1).toUpperCase()
+ r.substring(1).toLowerCase();
}
}
示例3: isInfraspecific
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
/**
* @param rank
* Set the rank
* @return true if the rank is infraspecific
*/
public static Boolean isInfraspecific(Rank rank) {
if (rank == null) {
return Boolean.FALSE;
} else {
if (rank.compareTo(Rank.SPECIES) > 0) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}
}
示例4: setUpTestData
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
/**
*
*/
@Override
public final void setUpTestData() {
Organisation source1 = createSource("test", "http://example.com", "Test Organisation", "[email protected]");
Organisation source2 = createSource("source2", "http://source2.com", "Test Organisation 2", "[email protected]");
Taxon taxon1 = createTaxon("Aus", "1", null, null, "Ausaceae", null,
null, "(1753)", Rank.GENUS, TaxonomicStatus.Accepted,
source1, new Location[] {}, new Organisation[] {source1});
Taxon taxon2 = createTaxon("Aus bus", "2", taxon1, null, "Ausaceae",
null, null, "(1775)", Rank.SPECIES, TaxonomicStatus.Accepted,
source1, new Location[] {Location.AUSTRALASIA,
Location.BRAZIL, Location.CARIBBEAN }, new Organisation[] {source1,source2});
Taxon taxon3 = createTaxon("Aus ceus", "3", taxon1, null, "Ausaceae",
null, null, "(1805)", Rank.SPECIES, TaxonomicStatus.Accepted,
source1, new Location[] {Location.NEW_ZEALAND }, new Organisation[] {source1,source2});
Taxon taxon4 = createTaxon("Aus deus", "4", null, taxon2, "Ausaceae",
null, null, "(1895)", Rank.SPECIES, TaxonomicStatus.Synonym,
source1, new Location[] {}, new Organisation[] {source1});
Taxon taxon5 = createTaxon("Aus eus", "5", null, taxon3, "Ausaceae",
null, null, "(1935)", Rank.SPECIES, TaxonomicStatus.Synonym,
source1, new Location[] {}, new Organisation[] {source1});
Image img1 = createImage("Aus", "1", source2,taxon2, new Organisation[] {source2,source1});
Image img2 = createImage("Aus bus", "2", source2,taxon2, new Organisation[] {source2,source1});
Place place1 = createPlace("gb", "Great Britain");
}
示例5: convert
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Override
public Rank convert(String source) {
if (source == null || source.isEmpty()) {
return null;
}
source = source.toLowerCase().trim();
for (Rank term : Rank.values()) {
if (term.toString().toLowerCase().equals(source)) {
return term;
}
}
return null;
}
示例6: convert
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Override
public String convert(Rank value) {
if (value == null) {
return null;
} else {
return value.name().toLowerCase();
}
}
示例7: getTopImages
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<Image> getTopImages(Taxon rootTaxon, int n) {
String queryTemplate = "select img from Image as img join img.taxon as taxon where %s order by img.rating desc";
Query q;
List<Long> rootImgs = new ArrayList<>();
for(Image img : rootTaxon.getImages()) {
rootImgs.add(img.getId());
}
if(!rootImgs.isEmpty()) {
queryTemplate = String.format(queryTemplate, "img.id not in (:rootImgs) and %s");
}
if(rootTaxon.getTaxonRank() != null && rootTaxon.getTaxonRank().equals(Rank.FAMILY)) {
q = getSession().createQuery(String.format(queryTemplate, "taxon.family = :family"));
q.setParameter("family", rootTaxon.getFamily());
if(!rootImgs.isEmpty()) q.setParameterList("rootImgs", rootImgs);
} else if (rootTaxon.getTaxonRank() != null && rootTaxon.getTaxonRank().equals(Rank.GENUS)) {
q = getSession().createQuery(String.format(queryTemplate, "taxon.family = :family and taxon.genus = :genus"));
q.setParameter("family", rootTaxon.getFamily());
q.setParameter("genus", rootTaxon.getGenus());
if(!rootImgs.isEmpty()) q.setParameterList("rootImgs", rootImgs);
} else {
// we don't want to add anything to species and below
q = getSession().createQuery("from Image where 1=0");
}
q.setMaxResults(n);
List<Image> ret = (List<Image>)q.list();
if(ret != null) {
return ret;
} else {
return new ArrayList<>();
}
}
示例8: childRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
public CharSequence childRank(Taxon taxon, Options options) {
int index = Arrays.asList(Rank.LINNEAN_RANKS).indexOf(taxon.getTaxonRank());
if(taxon.getTaxonRank() == Rank.FAMILY) {
return "Genera";
} else if(index == -1) {
return "Unknown Rank";
} else if(index == Rank.LINNEAN_RANKS.length - 1) {
return "Infraspecifics";
} else {
return WordUtils.capitalizeFully(Rank.LINNEAN_RANKS[index+1].toString());
}
}
示例9: setUp
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Before
public void setUp() {
taxon = new Taxon();
taxon.setIdentifier("urn:lsid:ipni.org:names:1-1");
taxon.setScientificName("Aralidiaceae");
taxon.setScientificNameAuthorship("Philipson & B.C.Stone");
taxon.setTaxonRank(Rank.FAMILY);
}
示例10: testClassification
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Test
public void testClassification() throws IOException {
Taxon child = new Taxon();
child.setIdentifier("111");
child.setScientificName("aaa");
child.setScientificNameAuthorship("L.");
child.setParentNameUsage(taxon);
child.setTaxonRank(Rank.GENUS);
shouldCompileTo("{{classification this}}", child,
"<ol><li>Family: <a href=\"/taxon/urn:lsid:ipni.org:names:1-1\"><em>Aralidiaceae</em> Philipson & B.C.Stone</a>"
+ "<ol><li><h1 class=\"c-summary__heading\"><em>aaa</em> <small>L.</small></h1></li>"
+ "<ol></li></ol>");
}
示例11: setUp
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Organisation source = createSource("test", "http://test.org", "test");
createTaxon("Quercus", "1", null, null, "Fagaceae", "Quercus", null, null, Rank.GENUS, TaxonomicStatus.Accepted, source, new Location[] {}, null);
createTaxon("Quercus alba", "2", null, null, "Fagaceae", "Quercus", null, null, Rank.GENUS, TaxonomicStatus.Accepted, source, new Location[] {}, null);
doSetUp();
}
示例12: indexRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
private void indexRank(Rank rank, String property) {
String solrField = propertyToSolrField(property, "s_lower");
try {
if(rank.equals(taxon.getTaxonRank()) && BeanUtils.getProperty(taxon, property) == null) {
addField(sid, solrField, taxon.getScientificName());
} else {
addField(sid, solrField, BeanUtils.getProperty(taxon, property));
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
logger.error("Error getting property {} from taxon. Does get{}() exist?", property, property);
}
}
示例13: taxonRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Test
public void taxonRank() {
Taxon taxon = new Taxon();
taxon.setTaxonRank(Rank.KINGDOM);
SolrInputDocument doc = new TaxonSolrInputDocument(taxon).build();
String field = "taxon.rank_s_lower";
assertTrue("Expected " + field, doc.containsKey(field));
assertEquals(Rank.KINGDOM.toString(), doc.getFieldValue(field));
}
示例14: createTaxon
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
/**
*
* @param name
* the name of the taxon
* @param identifier
* set the identifier of the taxon
* @param parent
* the taxonomic parent
* @param accepted
* the accepted name
* @param family
* the family
* @param genus
* the genus
* @param specificEpithet
* the specific epithet
* @param datePublished
* set the date published
* @param rank
* set the rank
* @param status
* set the status
* @param source set the source
* @param distributions
* the distribution of the taxon
* @param sources TODO
* @return a new taxon
*/
public Taxon createTaxon(String name,
String identifier,
Taxon parent, Taxon accepted, String family,
String genus, String specificEpithet,
String datePublished, Rank rank,
org.gbif.ecat.voc.TaxonomicStatus status, Organisation source,
Location[] distributions, Organisation[] sources) {
Taxon taxon = new Taxon();
taxon.setScientificName(name);
taxon.setFamily(family);
taxon.setGenus(genus);
taxon.setSpecificEpithet(specificEpithet);
taxon.setIdentifier(identifier);
taxon.setTaxonomicStatus(status);
taxon.setTaxonRank(rank);
taxon.setAuthority(source);
Reference reference = new Reference();
reference.setIdentifier(UUID.randomUUID().toString());
reference.setDate(datePublished);
taxon.setNamePublishedIn(reference);
if (parent != null) {
taxon.setParentNameUsage(parent);
parent.getChildNameUsages().add(taxon);
}
if (accepted != null) {
taxon.setAcceptedNameUsage(accepted);
accepted.getSynonymNameUsages().add(taxon);
}
for (Location region : distributions) {
Distribution distribution = new Distribution();
distribution.setIdentifier(UUID.randomUUID().toString());
distribution.setLocation(region);
distribution.setTaxon(taxon);
taxon.getDistribution().add(distribution);
}
setUp.add(taxon);
tearDown.push(taxon);
return taxon;
}
示例15: testFormatRank
import org.gbif.ecat.voc.Rank; //导入依赖的package包/类
@Test
public void testFormatRank() {
assertEquals("FAMILY should be formatted as Family",Functions.formatRank(Rank.FAMILY),"Family");
assertEquals("GENUS should be formatted as Genus",Functions.formatRank(Rank.GENUS),"Genus");
assertEquals("SPECIES should be formatted as Species",Functions.formatRank(Rank.SPECIES),"Species");
}