001/*
002 * Copyright 2014 Global Biodiversity Information Facility (GBIF)
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 * http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing, software
008 * distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and
011 * limitations under the License.
012 */
013package org.gbif.api.model.metrics.cube;
014
015import org.gbif.api.vocabulary.BasisOfRecord;
016import org.gbif.api.vocabulary.Country;
017import org.gbif.api.vocabulary.EndpointType;
018import org.gbif.api.vocabulary.OccurrenceIssue;
019import org.gbif.api.vocabulary.TypeStatus;
020
021import java.util.List;
022import java.util.UUID;
023
024import com.google.common.collect.ImmutableList;
025
026/**
027 * The occurrence cube dimension definitions and the way in which they are rolled up into counts.
028 */
029public class OccurrenceCube {
030
031  public static final Dimension<UUID> DATASET_KEY = new Dimension<UUID>("datasetKey", UUID.class);
032  public static final Dimension<Integer> TAXON_KEY = new Dimension<Integer>("taxonKey", Integer.class);
033  public static final Dimension<BasisOfRecord> BASIS_OF_RECORD = new Dimension<BasisOfRecord>("basisOfRecord", BasisOfRecord.class);
034  // georeferenced is different from hasCoordinate and includes a no geospatial issue check!
035  public static final Dimension<Boolean> IS_GEOREFERENCED = new Dimension<Boolean>("isGeoreferenced", Boolean.class);
036  public static final Dimension<Country> COUNTRY = new Dimension<Country>("country", Country.class);
037  public static final Dimension<Country> PUBLISHING_COUNTRY = new Dimension<Country>("publishingCountry", Country.class);
038  public static final Dimension<Integer> YEAR = new Dimension<Integer>("year", Integer.class);
039  public static final Dimension<EndpointType> PROTOCOL = new Dimension<EndpointType>("protocol", EndpointType.class);
040  public static final Dimension<TypeStatus> TYPE_STATUS = new Dimension<TypeStatus>("typeStatus", TypeStatus.class);
041  public static final Dimension<OccurrenceIssue> ISSUE = new Dimension<OccurrenceIssue>("issue", OccurrenceIssue.class);
042
043  public static final List<Dimension<?>> DIMENSIONS = ImmutableList.<Dimension<?>>of(COUNTRY, IS_GEOREFERENCED,
044         BASIS_OF_RECORD, PUBLISHING_COUNTRY, DATASET_KEY, TAXON_KEY, PROTOCOL, YEAR, TYPE_STATUS, ISSUE
045  );
046
047  // PLEASE KEEP THIS LIST MAINTAINED ALPHABETICALLY so we can spot duplicates and groupings
048  // sort rows as well as dimensions within each row
049  public static final List<Rollup> ROLLUPS = ImmutableList.of(
050    new Rollup(BASIS_OF_RECORD),
051    new Rollup(BASIS_OF_RECORD, COUNTRY),
052    new Rollup(BASIS_OF_RECORD, COUNTRY, IS_GEOREFERENCED),
053    new Rollup(BASIS_OF_RECORD, COUNTRY, IS_GEOREFERENCED, TAXON_KEY),
054    new Rollup(BASIS_OF_RECORD, COUNTRY, TAXON_KEY),
055    new Rollup(BASIS_OF_RECORD, DATASET_KEY),
056    new Rollup(BASIS_OF_RECORD, DATASET_KEY, IS_GEOREFERENCED),
057    new Rollup(BASIS_OF_RECORD, DATASET_KEY, IS_GEOREFERENCED, TAXON_KEY),
058    new Rollup(BASIS_OF_RECORD, DATASET_KEY, TAXON_KEY),
059    new Rollup(BASIS_OF_RECORD, IS_GEOREFERENCED, TAXON_KEY),
060    new Rollup(BASIS_OF_RECORD, IS_GEOREFERENCED, PUBLISHING_COUNTRY),
061    new Rollup(BASIS_OF_RECORD, IS_GEOREFERENCED, PUBLISHING_COUNTRY, TAXON_KEY),
062    new Rollup(BASIS_OF_RECORD, PUBLISHING_COUNTRY),
063    new Rollup(BASIS_OF_RECORD, PUBLISHING_COUNTRY, TAXON_KEY),
064    new Rollup(BASIS_OF_RECORD, TAXON_KEY),
065    new Rollup(COUNTRY),
066    new Rollup(COUNTRY, DATASET_KEY, IS_GEOREFERENCED),
067    new Rollup(COUNTRY, IS_GEOREFERENCED),
068    new Rollup(COUNTRY, IS_GEOREFERENCED, PUBLISHING_COUNTRY),
069    new Rollup(COUNTRY, IS_GEOREFERENCED, TAXON_KEY),
070    new Rollup(COUNTRY, PUBLISHING_COUNTRY),
071    new Rollup(COUNTRY, TAXON_KEY),
072    new Rollup(COUNTRY, TYPE_STATUS),
073    new Rollup(DATASET_KEY),
074    new Rollup(DATASET_KEY, IS_GEOREFERENCED),
075    new Rollup(DATASET_KEY, IS_GEOREFERENCED, TAXON_KEY),
076    new Rollup(DATASET_KEY, ISSUE),
077    new Rollup(DATASET_KEY, TAXON_KEY),
078    new Rollup(DATASET_KEY, TYPE_STATUS),
079    new Rollup(IS_GEOREFERENCED),
080    new Rollup(IS_GEOREFERENCED, PUBLISHING_COUNTRY),
081    new Rollup(IS_GEOREFERENCED, PUBLISHING_COUNTRY, TAXON_KEY),
082    new Rollup(IS_GEOREFERENCED, TAXON_KEY),
083    new Rollup(ISSUE),
084    new Rollup(PUBLISHING_COUNTRY),
085    new Rollup(PUBLISHING_COUNTRY, TAXON_KEY),
086    new Rollup(PUBLISHING_COUNTRY, TYPE_STATUS),
087    new Rollup(TAXON_KEY),
088    new Rollup(TAXON_KEY, TYPE_STATUS),
089    new Rollup(TYPE_STATUS),
090    new Rollup(PROTOCOL),
091    new Rollup(YEAR)
092    );
093
094  // Not intended for instantiation
095  private OccurrenceCube() {
096  }
097}