@Override protected void setUUID(AbstractMetadataRecord record) { if (count >= 0) { count = Integer.MIN_VALUE; } super.setUUID(record); } };
@Override protected void setUUID(AbstractMetadataRecord record) { if (count >= 0) { count = Integer.MIN_VALUE; } super.setUUID(record); } };
@Override protected void setUUID(AbstractMetadataRecord record) { if (count >= 0) { count = Integer.MIN_VALUE; } super.setUUID(record); } };
/** * Add a function with the given name to the model. * @param name * @return * @throws MetadataException */ public FunctionMethod addFunction(String name) { FunctionMethod function = new FunctionMethod(); function.setName(name); setUUID(function); this.schema.addFunction(function); return function; }
public MetadataFactory(String vdbName, Object vdbVersion, String schemaName, Map<String, Datatype> runtimeTypes, Properties modelProperties, String rawMetadata) { this.vdbName = vdbName; this.vdbVersion = vdbVersion.toString(); this.dataTypes = Collections.unmodifiableMap(runtimeTypes); this.schema.setName(schemaName); long msb = longHash(vdbName, 0); try { //if this is just an int, we'll use the old style hash int val = Integer.parseInt(this.vdbVersion); msb = 31*msb + val; } catch (NumberFormatException e) { msb = 31*msb + vdbVersion.hashCode(); } msb = longHash(schemaName, msb); this.idPrefix = "tid:" + hex(msb, 12); //$NON-NLS-1$ setUUID(this.schema); if (modelProperties != null) { for (Map.Entry<Object, Object> entry : modelProperties.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { this.schema.setProperty(resolvePropertyKey(this, (String) entry.getKey()), (String) entry.getValue()); } } PropertiesUtils.setBeanProperties(this, modelProperties, "importer"); //$NON-NLS-1$ } this.modelProperties = modelProperties; this.rawMetadata = rawMetadata; }
/** * Adds an access pattern to the given table. * @param name * @param columnNames * @param table * @return * @throws MetadataException */ public KeyRecord addAccessPattern(String name, List<String> columnNames, Table table) { KeyRecord ap = new KeyRecord(KeyRecord.Type.AccessPattern); ap.setParent(table); ap.setColumns(new ArrayList<Column>(columnNames.size())); ap.setName(name); setUUID(ap); assignColumns(columnNames, table, ap); table.getAccessPatterns().add(ap); return ap; }
/** * Adds a non-pushdown function based upon the given {@link Method}. * @param name * @param method * @return * @throws MetadataException */ public FunctionMethod addFunction(String name, Method method) { FunctionMethod func = createFunctionFromMethod(name, method); setFunctionMethodTypes(func); setUUID(func); getSchema().addFunction(func); return func; }
/** * Adds an index to the given table. * @param name * @param nonUnique true indicates that an index is being added. * @param columnNames * @param table * @return * @throws MetadataException */ public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) { KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.Index:KeyRecord.Type.Unique); index.setParent(table); index.setColumns(new ArrayList<Column>(columnNames.size())); index.setName(name); assignColumns(columnNames, table, index); setUUID(index); if (nonUnique) { table.getIndexes().add(index); } else { table.getUniqueKeys().add(index); } return index; }
/** * Adds a primary key to the given table. The column names should be in key order. * @param name * @param columnNames * @param table * @return * @throws MetadataException */ public KeyRecord addPrimaryKey(String name, List<String> columnNames, Table table) { KeyRecord primaryKey = new KeyRecord(KeyRecord.Type.Primary); primaryKey.setParent(table); primaryKey.setColumns(new ArrayList<Column>(columnNames.size())); primaryKey.setName(name); setUUID(primaryKey); assignColumns(columnNames, table, primaryKey); table.setPrimaryKey(primaryKey); return primaryKey; }
/** * Add a function with the given name to the model. * @param name * @return * @throws MetadataException */ public FunctionMethod addFunction(String name, String returnType, String... paramTypes) { FunctionMethod function = FunctionMethod.createFunctionMethod(name, null, null, returnType, paramTypes); setFunctionMethodTypes(function); function.setPushdown(PushDown.MUST_PUSHDOWN); setUUID(function); schema.addFunction(function); return function; }
index.setColumns(new ArrayList<Column>(expressions.size())); index.setName(name); setUUID(index); boolean functionBased = false; for (int i = 0; i < expressions.size(); i++) { setUUID(c); c.setParent(index); c.setPosition(i + 1); //position is temporarily relative to the index, but the validator changes this
/** * Adds a foreign key to the given table. The referenced key may be automatically created if addUniqueConstraint is true. The column names should be in key order. * if reference table is is another schema, they will be resolved during validation. * @param name * @param columnNames * @param referencedColumnNames, may be null to indicate that the primary key should be used. * @param referenceTable - schema qualified reference table name, can be from another schema * @param table * @param addUniqueConstraint - if true, if the referenced table columns do not match with either PK, or FK then a UNIQUE index on reference table is created. * @return * @throws MetadataException */ public ForeignKey addForeignKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table) { ForeignKey foreignKey = new ForeignKey(); foreignKey.setParent(table); foreignKey.setColumns(new ArrayList<Column>(columnNames.size())); assignColumns(columnNames, table, foreignKey); foreignKey.setReferenceTableName(referenceTable); foreignKey.setReferenceColumns(referencedColumnNames); foreignKey.setName(name); setUUID(foreignKey); table.getForeignKeys().add(foreignKey); return foreignKey; }
/** * Add a procedure with the given name to the model. * @param name * @return * @throws MetadataException */ public Procedure addProcedure(String name) { Assertion.isNotNull(name, "name cannot be null"); //$NON-NLS-1$ Procedure procedure = new Procedure(); if (nameFormat != null) { name = String.format(nameFormat, name); } if (renameAllDuplicates) { name = checkForDuplicate(name, (s)->this.schema.getProcedure(s) != null, "Procedure"); //$NON-NLS-1$ } procedure.setName(name); setUUID(procedure); procedure.setParameters(new LinkedList<ProcedureParameter>()); this.schema.addProcedure(procedure); return procedure; }
/** * Add a procedure parameter. * @param name * @param type should be one of {@link TypeFacility.RUNTIME_NAMES} * @param parameterType should be one of {@link ProcedureParameter.Type} * @param procedure * @return * @throws MetadataException */ public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure) { ProcedureParameter param = new ProcedureParameter(); if (renameAllDuplicates) { name = checkForDuplicate(name, (s)->procedure.getParameterByName(s) != null, "Parameter"); //$NON-NLS-1$ } param.setName(name); setUUID(param); param.setType(parameterType); param.setProcedure(procedure); setDataType(type, param, this.dataTypes, false); if (parameterType == Type.ReturnValue) { procedure.getParameters().add(0, param); for (int i = 0; i < procedure.getParameters().size(); i++) { procedure.getParameters().get(i).setPosition(i+1); //1 based indexing } } else { procedure.getParameters().add(param); param.setPosition(procedure.getParameters().size()); //1 based indexing } return param; }
/** * Add a table with the given name to the model. * @param name * @return * @throws MetadataException */ public Table addTable(String name) { Table table = new Table(); table.setTableType(Table.Type.Table); if (nameFormat != null) { name = String.format(nameFormat, name); } if (renameAllDuplicates || renameDuplicateTables) { name = checkForDuplicate(name, (s)->this.schema.getTable(s) != null, "Table"); //$NON-NLS-1$ } table.setName(name); setUUID(table); this.schema.addTable(table); table.setVirtual(!this.schema.isPhysical()); return table; }
setUUID(column); return column;
/** * Add a procedure resultset column to the given procedure. * @param name * @param type should be one of {@link TypeFacility.RUNTIME_NAMES} * @param procedure * @return * @throws MetadataException */ public Column addProcedureResultSetColumn(String name, String type, Procedure procedure) { if (procedure.getResultSet() == null) { ColumnSet<Procedure> resultSet = new ColumnSet<Procedure>(); resultSet.setParent(procedure); resultSet.setName("RSParam"); //$NON-NLS-1$ setUUID(resultSet); procedure.setResultSet(resultSet); } return addColumn(name, type, procedure.getResultSet()); }