use of org.jkiss.dbeaver.ext.mockdata.model.MockGeneratorRegistry in project dbeaver by dbeaver.
the class MockDataSettings method init.
// populate attribute generators properties map
public void init(MockDataExecuteWizard wizard) throws DBException {
List<DBSDataManipulator> databaseObjects = wizard.getDatabaseObjects();
// TODO only the first
DBSDataManipulator dataManipulator = databaseObjects.iterator().next();
entity = (DBSEntity) dataManipulator;
attributes = new ArrayList<>();
try {
DBeaverUI.run(wizard.getContainer(), true, true, new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
attributes.addAll(DBUtils.getRealAttributes(entity.getAttributes(monitor)));
MockGeneratorRegistry generatorRegistry = MockGeneratorRegistry.getInstance();
for (DBSAttributeBase attribute : attributes) {
AttributeGeneratorProperties generatorProperties = new AttributeGeneratorProperties(attribute);
attributeGenerators.put(attribute.getName(), generatorProperties);
// ((JDBCColumnKeyType) attribute).isInUniqueKey()
List<DBSEntityReferrer> attributeReferrers = DBUtils.getAttributeReferrers(monitor, (DBSEntityAttribute) attribute);
if (!CommonUtils.isEmpty(attributeReferrers)) {
MockGeneratorDescriptor generator = generatorRegistry.getGenerator(FK_GENERATOR_ID);
putGenerator(generatorProperties, generator);
} else {
List<MockGeneratorDescriptor> generators = generatorRegistry.findAllGenerators(dataManipulator.getDataSource(), attribute);
for (MockGeneratorDescriptor generator : generators) {
putGenerator(generatorProperties, generator);
}
}
}
} catch (DBException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
DBUserInterface.getInstance().showError("Transfer init failed", "Can't start data transfer", e.getTargetException());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations