Tabnine Logo
UniqueConstraint
Code IndexAdd Tabnine to your IDE (free)

How to use
UniqueConstraint
in
it.unibz.inf.ontop.dbschema

Best Java code snippets using it.unibz.inf.ontop.dbschema.UniqueConstraint (Showing top 20 results out of 315)

origin: it.unibz.inf.ontop/ontop-optimization

private boolean isUcMatching(UniqueConstraint uniqueConstraint,
               ImmutableList<? extends VariableOrGroundTerm> leftArguments,
               ImmutableList<? extends VariableOrGroundTerm> rightArguments) {
  return uniqueConstraint.getAttributes().stream()
      .allMatch(a -> leftArguments.get(a.getIndex() -1)
          .equals(rightArguments.get(a.getIndex() - 1))
          // Excludes nullable attributes for the moment. TODO: reconsider it
          && !a.canNull());
}
origin: ontop/ontop

  /**
   * builds a UNIQUE constraint (this includes PRIMARY KEY)
   * 
   * @param name
   * @return null if the list of attributes is empty
   */
  
  public UniqueConstraint build(String name, boolean isPK) {
    ImmutableList<Attribute> attributes = builder.build();
    if (attributes.isEmpty())
      return null;
    return new UniqueConstraint(name, isPK, builder.build());
  }
}
origin: ontop/ontop

@Override
public ImmutableSet<Attribute> getDependents() {
  return getRelation().getAttributes().stream()
      .filter(a -> !attributes.contains(a))
      .collect(ImmutableCollectors.toSet());
}

origin: ontop/ontop

/**
 * adds a unique constraint (a primary key or a unique constraint proper)
 *
 * @param uc
 */

public void addUniqueConstraint(UniqueConstraint uc) {
  if (uc.isPrimaryKey()) {
    if (pk != null)
      throw new IllegalArgumentException("Duplicate PK " + pk + " " + uc);
    pk = uc;
  }
  else {
    if (pk != null)
      if (uc.getAttributes().equals(pk.getAttributes()))
        // ignore the unique index created for the primary key
        return;
  }
  ucs.add(uc);
}

origin: ontop/ontop

private static void extractPrimaryKey(DatabaseRelationDefinition relation, QuotedIDFactory idfac, RelationID id, ResultSet rs) throws SQLException {
  Map<Integer, String> primaryKeyAttributes = new HashMap<>();
  String currentName = null;
  while (rs.next()) {
    // TABLE_CAT is ignored for now; assume here that relation has a fully specified name
    RelationID id2 = RelationID.createRelationIdFromDatabaseRecord(idfac,
              rs.getString("TABLE_SCHEM"), rs.getString("TABLE_NAME"));
    if (id2.equals(id)) {
      currentName = rs.getString("PK_NAME"); // may be null
      String attr = rs.getString("COLUMN_NAME");
      int seq = rs.getShort("KEY_SEQ");
      primaryKeyAttributes.put(seq, attr);
    }
  }
  if (!primaryKeyAttributes.isEmpty()) {
    // use the KEY_SEQ values to restore the correct order of attributes in the PK
    UniqueConstraint.Builder builder = UniqueConstraint.builder(relation);
    for (int i = 1; i <= primaryKeyAttributes.size(); i++) {
      QuotedID attrId = QuotedID.createIdFromDatabaseRecord(idfac, primaryKeyAttributes.get(i));
      builder.add(relation.getAttribute(attrId));
    }
    relation.addUniqueConstraint(builder.build(currentName, true));
  }
}
origin: it.unibz.inf.ontop/ontop-model

/**
 * adds a unique constraint (a primary key or a unique constraint proper)
 *
 * @param uc
 */

public void addUniqueConstraint(UniqueConstraint uc) {
  if (uc.isPrimaryKey()) {
    if (pk != null)
      throw new IllegalArgumentException("Duplicate PK " + pk + " " + uc);
    pk = uc;
  }
  else {
    if (pk != null)
      if (uc.getAttributes().equals(pk.getAttributes()))
        // ignore the unique index created for the primary key
        return;
  }
  ucs.add(uc);
}

origin: it.unibz.inf.ontop/ontop-rdb

UniqueConstraint.Builder builder = UniqueConstraint.builder(relation);
for (int i = 1; i <= primaryKeyAttributes.size(); i++) {
  QuotedID attrId = QuotedID.createIdFromDatabaseRecord(idfac, primaryKeyAttributes.get(i));
origin: ontop/ontop

private Stream<Map.Entry<RelationPredicate, ImmutableList<Integer>>> extractUniqueConstraintsFromRelation(
    DatabaseRelationDefinition relation) {
  return relation.getUniqueConstraints().stream()
      .map(uc -> uc.getAttributes().stream()
          .map(Attribute::getIndex)
          .collect(ImmutableCollectors.toList()))
      .map(positions -> new AbstractMap.SimpleEntry<>(relation.getAtomPredicate(), positions));
}
origin: ontop/ontop

builder = UniqueConstraint.builder(relation);
currentName = rs.getString("INDEX_NAME");
origin: it.unibz.inf.ontop/ontop-model

@Override
public ImmutableSet<Attribute> getDependents() {
  return getRelation().getAttributes().stream()
      .filter(a -> !attributes.contains(a))
      .collect(ImmutableCollectors.toSet());
}

origin: it.unibz.inf.ontop/ontop-model

  /**
   * builds a UNIQUE constraint (this includes PRIMARY KEY)
   * 
   * @param name
   * @return null if the list of attributes is empty
   */
  
  public UniqueConstraint build(String name, boolean isPK) {
    ImmutableList<Attribute> attributes = builder.build();
    if (attributes.isEmpty())
      return null;
    return new UniqueConstraint(name, isPK, builder.build());
  }
}
origin: ontop/ontop

private boolean isUcMatching(UniqueConstraint uniqueConstraint,
               ImmutableList<? extends VariableOrGroundTerm> leftArguments,
               ImmutableList<? extends VariableOrGroundTerm> rightArguments) {
  return uniqueConstraint.getAttributes().stream()
      .allMatch(a -> leftArguments.get(a.getIndex() -1)
          .equals(rightArguments.get(a.getIndex() - 1))
          // Excludes nullable attributes for the moment. TODO: reconsider it
          && !a.canNull());
}
origin: it.unibz.inf.ontop/ontop-rdb

builder = UniqueConstraint.builder(relation);
currentName = rs.getString("INDEX_NAME"); 
origin: it.unibz.inf.ontop/ontop-model

private Stream<Map.Entry<AtomPredicate, ImmutableList<Integer>>> extractUniqueConstraintsFromRelation(
    DatabaseRelationDefinition relation, Map<Predicate, AtomPredicate> predicateCache) {
  Predicate originalPredicate = Relation2Predicate.createPredicateFromRelation(relation);
  AtomPredicate atomPredicate = convertToAtomPredicate(originalPredicate, predicateCache);
  return relation.getUniqueConstraints().stream()
      .map(uc -> uc.getAttributes().stream()
          .map(Attribute::getIndex)
          .collect(ImmutableCollectors.toList()))
      .map(positions -> new AbstractMap.SimpleEntry<>(atomPredicate, positions));
}
origin: ontop/ontop

  continue;
UniqueConstraint.Builder builder = UniqueConstraint.builder(td);
String[] attrs = uc[1].split(",");
for (String attr : attrs) {
origin: it.unibz.inf.ontop/ontop-mapping-sql-owlapi

private static List<Attribute> getIdentifyingAttributes(DatabaseRelationDefinition table) {
  UniqueConstraint pk = table.getPrimaryKey();
  if (pk != null)
    return pk.getAttributes();
  else
    return table.getAttributes();
}

origin: it.unibz.inf.ontop/ontop-mapping-core

  continue;
UniqueConstraint.Builder builder = UniqueConstraint.builder(td);
String[] attrs = uc[1].split(",");
for (String attr : attrs) {
origin: ontop/ontop

private static List<Attribute> getIdentifyingAttributes(DatabaseRelationDefinition table) {
  UniqueConstraint pk = table.getPrimaryKey();
  if (pk != null)
    return pk.getAttributes();
  else
    return table.getAttributes();
}

origin: ontop/ontop

private ImmutableSet<Integer> extractNonMatchedRightAttributeIndexes(ImmutableCollection<UniqueConstraint> matchedUCs,
                                   ImmutableCollection<ForeignKeyConstraint> matchedFKs,
                                   int arity) {
  return IntStream.range(0, arity)
      .filter(i -> (matchedUCs.stream()
          .noneMatch(uc ->
              uc.getAttributes().stream()
                  .anyMatch(a -> a.getIndex() == (i + 1)))))
      .filter(i -> (matchedFKs.stream()
          .noneMatch(fk ->
              fk.getComponents().stream()
                  .anyMatch(c -> c.getReference().getIndex() == (i + 1)))))
      .boxed()
      .collect(ImmutableCollectors.toSet());
}
origin: it.unibz.inf.ontop/ontop-optimization

private ImmutableSet<Integer> extractNonMatchedRightAttributeIndexes(ImmutableCollection<UniqueConstraint> matchedUCs,
                                   ImmutableCollection<ForeignKeyConstraint> matchedFKs,
                                   int arity) {
  return IntStream.range(0, arity)
      .filter(i -> (matchedUCs.stream()
          .noneMatch(uc ->
              uc.getAttributes().stream()
                  .anyMatch(a -> a.getIndex() == (i + 1)))))
      .filter(i -> (matchedFKs.stream()
          .noneMatch(fk ->
              fk.getComponents().stream()
                  .anyMatch(c -> c.getReference().getIndex() == (i + 1)))))
      .boxed()
      .collect(ImmutableCollectors.toSet());
}
it.unibz.inf.ontop.dbschemaUniqueConstraint

Javadoc

Primary key or a unique constraint
PRIMARY KEY (columnName (, columnName)*)
UNIQUE (columnName (, columnName)*)
(a form of equality-generating dependencies)

Most used methods

  • getAttributes
    return the list of attributes in the unique constraint
  • builder
    creates a UNIQUE constraint builder (which is also used for a PRIMARY KET builder)
  • <init>
  • getRelation
    return the database relation for the unique constraint
  • isPrimaryKey
    return true if it is a primary key and false otherwise

Popular in Java

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • putExtra (Intent)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now