All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.torodb.backend.tables.MetaDocPartTable Maven / Gradle / Ivy

There is a newer version: 0.50.3
Show newest version
/*
 * ToroDB
 * Copyright © 2014 8Kdata Technology (www.8kdata.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see .
 */

package com.torodb.backend.tables;

import com.google.common.collect.ImmutableList;
import com.torodb.backend.InternalField;
import com.torodb.backend.InternalField.DidInternalField;
import com.torodb.backend.InternalField.PidInternalField;
import com.torodb.backend.InternalField.RidInternalField;
import com.torodb.backend.InternalField.SeqInternalField;
import com.torodb.backend.meta.TorodbSchema;
import com.torodb.backend.tables.records.MetaDocPartRecord;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.jooq.Field;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.UniqueKey;
import org.jooq.impl.AbstractKeys;

import java.util.Arrays;
import java.util.List;

@SuppressFBWarnings(
    value = "HE_HASHCODE_NO_EQUALS",
    justification =
    "Equals comparation is done in TableImpl class, which compares schema, name and fields")
@SuppressWarnings({"checkstyle:LineLength", "checkstyle:AbbreviationAsWordInName",
    "checkstyle:MemberName"})
public abstract class MetaDocPartTable>
    extends SemanticTable {

  private static final long serialVersionUID = 1664366669485866827L;

  public static final String TABLE_NAME = "doc_part";

  public enum TableFields {
    DATABASE("database"),
    COLLECTION("collection"),
    TABLE_REF("table_ref"),
    IDENTIFIER("identifier"),
    LAST_RID("last_rid");

    public final String fieldName;

    TableFields(String fieldName) {
      this.fieldName = fieldName;
    }

    @Override
    public String toString() {
      return fieldName;
    }
  }

  public enum DocPartTableFields {
    DID("did"),
    RID("rid"),
    PID("pid"),
    SEQ("seq"),
    SCALAR("v"),;

    public final String fieldName;

    DocPartTableFields(String fieldName) {
      this.fieldName = fieldName;
    }

    @Override
    public String toString() {
      return fieldName;
    }
  }

  /**
   * The class holding records for this type
   *
   * @return
   */
  @Override
  public abstract Class getRecordType();

  /**
   * The column torodb.container.database.
   */
  public final TableField DATABASE =
      createDatabaseField();

  /**
   * The column torodb.container.collection.
   */
  public final TableField COLLECTION =
      createCollectionField();

  /**
   * The column torodb.container.path.
   */
  public final TableField TABLE_REF =
      createTableRefField();

  /**
   * The column torodb.container.table_name.
   */
  public final TableField IDENTIFIER =
      createIdentifierField();

  /**
   * The column torodb.container.last_rid.
   */
  public final TableField LAST_RID =
      createLastRidField();

  public final InternalField DID =
      new DidInternalField(createDidField());
  public final InternalField RID =
      new RidInternalField(createRidField());
  public final InternalField PID =
      new PidInternalField(createPidField());
  public final InternalField SEQ =
      new SeqInternalField(createSeqField());

  public final ImmutableList> ROOT_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .build();
  public final ImmutableList> FIRST_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .add(RID)
      .add(SEQ)
      .build();
  public final ImmutableList> FIELDS = ImmutableList.>builder()
      .add(DID)
      .add(RID)
      .add(PID)
      .add(SEQ)
      .build();

  public final ImmutableList> PRIMARY_KEY_ROOT_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .build();
  public final ImmutableList> PRIMARY_KEY_FIRST_FIELDS = ImmutableList
      .>builder()
      .add(RID)
      .build();
  public final ImmutableList> PRIMARY_KEY_FIELDS = ImmutableList
      .>builder()
      .add(RID)
      .build();

  public final ImmutableList> REFERENCE_FIRST_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .build();
  public final ImmutableList> REFERENCE_FIELDS = ImmutableList
      .>builder()
      .add(PID)
      .build();

  public final ImmutableList> FOREIGN_ROOT_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .build();
  public final ImmutableList> FOREIGN_FIRST_FIELDS = ImmutableList
      .>builder()
      .add(RID)
      .build();
  public final ImmutableList> FOREIGN_FIELDS = ImmutableList
      .>builder()
      .add(RID)
      .build();

  public final ImmutableList> READ_ROOT_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .build();
  public final ImmutableList> READ_FIRST_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .add(SEQ)
      .build();
  public final ImmutableList> READ_FIELDS = ImmutableList
      .>builder()
      .add(DID)
      .add(PID)
      .add(SEQ)
      .build();

  protected abstract TableField createDatabaseField();

  protected abstract TableField createCollectionField();

  protected abstract TableField createTableRefField();

  protected abstract TableField createIdentifierField();

  protected abstract TableField createLastRidField();

  protected abstract Field createDidField();

  protected abstract Field createRidField();

  protected abstract Field createPidField();

  protected abstract Field createSeqField();

  private final UniqueKeys uniqueKeys;

  /**
   * Create a torodb.doc_part table reference
   */
  public MetaDocPartTable() {
    this(TABLE_NAME, null);
  }

  protected MetaDocPartTable(String alias, Table aliased) {
    this(alias, aliased, null);
  }

  protected MetaDocPartTable(String alias, Table aliased, Field[] parameters) {
    super(alias, TorodbSchema.TORODB, aliased, parameters, "");

    this.uniqueKeys = new UniqueKeys(this);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public UniqueKey getPrimaryKey() {
    return uniqueKeys.CONTAINER_PKEY;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public List> getKeys() {
    return Arrays.>asList(uniqueKeys.CONTAINER_PKEY,
        uniqueKeys.CONTAINER_TABLE_NAME_UNIQUE);
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public abstract MetaDocPartTable as(String alias);

  /**
   * Rename this table
   */
  public abstract MetaDocPartTable rename(String name);

  public UniqueKeys getUniqueKeys() {
    return uniqueKeys;
  }

  @SuppressWarnings({"checkstyle:LineLength", "checkstyle:AbbreviationAsWordInName",
      "checkstyle:MemberName"})
  public static class UniqueKeys>
      extends AbstractKeys {

    private final UniqueKey CONTAINER_PKEY;
    private final UniqueKey CONTAINER_TABLE_NAME_UNIQUE;

    private UniqueKeys(MetaDocPartTable containerTable) {
      CONTAINER_PKEY = createUniqueKey(containerTable, containerTable.DATABASE,
          containerTable.COLLECTION, containerTable.TABLE_REF);
      CONTAINER_TABLE_NAME_UNIQUE = createUniqueKey(containerTable, containerTable.DATABASE,
          containerTable.IDENTIFIER);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy