use of orgomg.cwm.resource.relational.Table in project tdq-studio-se by Talend.
the class AddTdRelationalSwitch method caseForeignKey.
@Override
public Boolean caseForeignKey(ForeignKey object) {
ColumnSet columnSet = null;
TdColumn tdColumn = null;
if (leftElement instanceof TdColumn) {
tdColumn = (TdColumn) leftElement;
columnSet = ColumnHelper.getColumnOwnerAsColumnSet(tdColumn);
}
if (columnSet == null) {
return Boolean.FALSE;
}
String fkName = object.getName();
ForeignKey foreignKey = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createForeignKey();
foreignKey.setName(fkName);
if (columnSet instanceof Table) {
foreignKey = TableHelper.addForeignKey((TdTable) columnSet, foreignKey);
if (tdColumn != null) {
tdColumn.getKeyRelationship().add(foreignKey);
}
}
return Boolean.TRUE;
}
use of orgomg.cwm.resource.relational.Table in project tdq-studio-se by Talend.
the class AddTdRelationalSwitch method casePrimaryKey.
@Override
public Boolean casePrimaryKey(PrimaryKey object) {
ColumnSet columnSet = null;
TdColumn tdColumn = null;
if (leftElement instanceof TdColumn) {
tdColumn = (TdColumn) leftElement;
columnSet = ColumnHelper.getColumnOwnerAsColumnSet(tdColumn);
}
if (columnSet == null) {
return Boolean.FALSE;
}
String pkName = object.getName();
PrimaryKey primaryKey = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createPrimaryKey();
primaryKey.setName(pkName);
if (columnSet instanceof Table) {
primaryKey = TableHelper.addPrimaryKey((TdTable) columnSet, primaryKey);
if (tdColumn != null) {
tdColumn.getUniqueKey().add(primaryKey);
}
}
return Boolean.TRUE;
}
use of orgomg.cwm.resource.relational.Table in project tdq-studio-se by Talend.
the class AnalysisHandler method getColumnSetOwnerNames.
private String[] getColumnSetOwnerNames() {
List<String> existingTables = new ArrayList<String>();
for (ModelElement element : getAnalyzedColumns()) {
if (element instanceof TdColumn && element.eContainer() instanceof Table) {
String tableName = ColumnHelper.getTableFullName((TdColumn) element);
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} else if (element instanceof Table) {
String tableName = ((Table) element).getName();
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} else if (element instanceof MetadataColumn) {
// the result page
if (!(element instanceof TdColumn)) {
// MOD qiongli 2011-1-28,for delimited file
try {
MetadataTable table = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) element);
String tableName = table.getLabel();
if (!existingTables.contains(tableName)) {
existingTables.add(tableName);
}
} catch (java.lang.NullPointerException e) {
// $NON-NLS-1$
log.error(Messages.getString("AnalysisHandler.CanNotFindColumnParent", element.getName()), e);
}
}
}
}
return existingTables.toArray(new String[existingTables.size()]);
}
Aggregations