@Override
    public void insertUniqueConstraints(DBMetadata md) {
        QuotedIDFactory idfac = md.getQuotedIDFactory();
        int counter = 0; // id of the generated constraint

        for (String[] uc : ucs) {
            RelationID tableId = getRelationIDFromString(uc[0], idfac);
            DatabaseRelationDefinition td = md.getDatabaseRelation(tableId);

            if (td == null) {
                log.warn("Error in user-supplied unique constraint: table " + tableId + " not found.");
                continue;
            }
            UniqueConstraint.Builder builder = UniqueConstraint.builder(td);
            String[] attrs = uc[1].split(",");
            for (String attr : attrs) {
                QuotedID attrId = idfac.createAttributeID(attr);
                Attribute attribute = td.getAttribute(attrId);
                if (attribute == null) {
                    log.warn("Error in user-supplied unique constraint: column " + attrId + " not found in table " + tableId + ".");
                    builder = null;
                    break;
                }
                //td.setAttribute(key_pos, new Attribute(td, attr.getName(), attr.getType(), false, attr.getSQLTypeName())); // true
                // ROMAN (17 Aug 2015): do we really change it into NON NULL?
                builder.add(attribute);
            }
            if (builder != null) // if all attributes have been identified
                td.addUniqueConstraint(builder.build(td.getID().getTableName() + "_USER_UC_" + counter, false));
            counter++;
        }
    }
@ Override public void insertUniqueConstraints ( DBMetadata md ) { QuotedIDFactory idfac = md . getQuotedIDFactory ( ) ; int counter = 0 ; for ( String [ ] uc : ucs ) { RelationID tableId = getRelationIDFromString ( uc [ 0 ] , idfac ) ; DatabaseRelationDefinition td = md . getDatabaseRelation ( tableId ) ; if ( td == null ) { log . warn ( "Error in user-supplied unique constraint: table " + tableId + " not found." ) ; continue ; } UniqueConstraint . Builder builder = UniqueConstraint . builder ( td ) ; String [ ] attrs = uc [ 1 ] . split ( "," ) ; for ( String attr : attrs ) { QuotedID attrId = idfac . createAttributeID ( attr ) ; Attribute attribute = td . getAttribute ( attrId ) ; if ( attribute == null ) { log . warn ( "Error in user-supplied unique constraint: column " + attrId + " not found in table " + tableId + "." ) ; builder = null ; break ; } builder . add ( attribute ) ; } if ( builder != null ) td . addUniqueConstraint ( builder . build ( td . getID ( ) . getTableName ( ) + "_USER_UC_" + counter , false ) ) ; counter ++ ; } }
Inserts the user-supplied primary keys / unique constraints columns into the metadata object

TODO: refactor into an immutable style