use of org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry in project tdi-studio-se by Talend.
the class AbstractDBDataMapTableImpl method equals.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated not
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
AbstractDBDataMapTableImpl other = (AbstractDBDataMapTableImpl) obj;
if (this.minimized != other.minimized) {
return false;
}
if (this.name == null) {
if (other.name != null) {
return false;
}
} else if (!this.name.equals(other.name)) {
return false;
}
if (this.tableName == null) {
if (other.tableName != null) {
return false;
}
} else if (!this.tableName.equals(other.tableName)) {
return false;
}
EList<DBMapperTableEntry> otherEntriss = other.getDBMapperTableEntries();
if (getDBMapperTableEntries().size() != otherEntriss.size()) {
return false;
}
for (DBMapperTableEntry entry : dbMapperTableEntries) {
boolean found = false;
for (DBMapperTableEntry otherEntry : otherEntriss) {
if (entry.getName().equals(otherEntry.getName())) {
found = true;
if (!entry.equals(otherEntry)) {
return false;
}
break;
}
}
if (found == false) {
return false;
}
}
return true;
}
use of org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry in project tdi-studio-se by Talend.
the class DbMapComponent method buildExternalData.
@Override
public void buildExternalData(AbstractExternalData abstractData) {
externalData = new ExternalDbMapData();
if (abstractData instanceof DBMapData) {
DBMapData mapperData = (DBMapData) abstractData;
List<ExternalDbMapTable> externalTables = new ArrayList<ExternalDbMapTable>();
// input
for (InputTable pTable : mapperData.getInputTables()) {
ExternalDbMapTable externalTable = new ExternalDbMapTable();
externalTable.setName(pTable.getName());
externalTable.setMinimized(pTable.isMinimized());
externalTable.setAlias(pTable.getAlias());
externalTable.setJoinType(pTable.getJoinType());
externalTable.setTableName(pTable.getTableName());
List<ExternalDbMapEntry> entities = new ArrayList<ExternalDbMapEntry>();
for (DBMapperTableEntry pEntity : pTable.getDBMapperTableEntries()) {
ExternalDbMapEntry entity = new ExternalDbMapEntry();
entity.setExpression(pEntity.getExpression());
entity.setJoin(pEntity.isJoin());
entity.setName(pEntity.getName());
entity.setOperator(pEntity.getOperator());
entities.add(entity);
}
externalTable.setMetadataTableEntries(entities);
externalTables.add(externalTable);
}
externalData.setInputTables(externalTables);
// output
externalTables = new ArrayList<ExternalDbMapTable>();
for (OutputTable pTable : mapperData.getOutputTables()) {
ExternalDbMapTable externalTable = new ExternalDbMapTable();
externalTable.setName(pTable.getName());
externalTable.setMinimized(pTable.isMinimized());
externalTable.setTableName(pTable.getTableName());
List<ExternalDbMapEntry> entities = new ArrayList<ExternalDbMapEntry>();
for (DBMapperTableEntry pEntity : pTable.getDBMapperTableEntries()) {
ExternalDbMapEntry entity = new ExternalDbMapEntry();
entity.setExpression(pEntity.getExpression());
entity.setName(pEntity.getName());
entities.add(entity);
}
externalTable.setMetadataTableEntries(entities);
// filters
entities = new ArrayList<ExternalDbMapEntry>();
List<ExternalDbMapEntry> otherFilterEntities = new ArrayList<ExternalDbMapEntry>();
for (FilterEntry pFilter : pTable.getFilterEntries()) {
ExternalDbMapEntry entity = new ExternalDbMapEntry();
entity.setExpression(pFilter.getExpression());
entity.setName(pFilter.getName());
if (FilterTableEntry.OTHER_FILTER.equals(pFilter.getFilterKind())) {
otherFilterEntities.add(entity);
} else {
entities.add(entity);
}
}
externalTable.setCustomWhereConditionsEntries(entities);
externalTable.setCustomOtherConditionsEntries(otherFilterEntities);
externalTables.add(externalTable);
}
externalData.setOutputTables(externalTables);
}
this.setExternalData(externalData);
}
use of org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry in project tdi-studio-se by Talend.
the class DBMapDataImplTest method test3.
private void test3() {
DBMapDataImpl mapData1 = new DBMapDataImpl();
DBMapDataImpl mapData2 = new DBMapDataImpl();
assertTrue(mapData1.equals(mapData2));
final OutputTable persistentTable = DbmapFactory.eINSTANCE.createOutputTable();
persistentTable.setMinimized(true);
persistentTable.setName("table1");
persistentTable.setTableName("tableName");
final DBMapperTableEntry emfMapperTableEntry = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
emfMapperTableEntry.setExpression("expression1");
emfMapperTableEntry.setName("entityName1");
emfMapperTableEntry.setJoin(true);
emfMapperTableEntry.setOperator("operator1");
persistentTable.getDBMapperTableEntries().add(emfMapperTableEntry);
mapData1.getOutputTables().add(persistentTable);
final OutputTable persistentTable2 = DbmapFactory.eINSTANCE.createOutputTable();
persistentTable2.setMinimized(true);
persistentTable2.setName("table1");
persistentTable2.setTableName("tableName");
final DBMapperTableEntry emfMapperTableEntry2 = DbmapFactory.eINSTANCE.createDBMapperTableEntry();
emfMapperTableEntry2.setExpression("expression1");
emfMapperTableEntry2.setName("entityName1");
emfMapperTableEntry2.setJoin(true);
emfMapperTableEntry2.setOperator("operator1");
persistentTable2.getDBMapperTableEntries().add(emfMapperTableEntry2);
mapData2.getOutputTables().add(persistentTable2);
assertTrue(mapData1.equals(mapData2));
}
use of org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry in project tdi-studio-se by Talend.
the class DbMapServiceTest method testUpdateEMFDBMapData.
@Test
public void testUpdateEMFDBMapData() {
DbMapService service = new DbMapService();
service.updateEMFDBMapData(nodeType, oldValue, newValue);
DBMapData data = (DBMapData) nodeType.getNodeData();
InputTable input = data.getInputTables().get(0);
assertEquals("context.schema.context.table", input.getName());
assertEquals("context.schema.context.table", input.getTableName());
OutputTable out = data.getOutputTables().get(0);
// output connection name should not be updated.
assertEquals("output", out.getName());
DBMapperTableEntry outEntry = out.getDBMapperTableEntries().get(0);
assertEquals("context.schema.context.table.column", outEntry.getExpression());
}
use of org.talend.designer.dbmap.model.emf.dbmap.DBMapperTableEntry in project tdi-studio-se by Talend.
the class DbMapService method updateEMFDBMapData.
@Override
public void updateEMFDBMapData(NodeType nodeType, String oldValue, String newValue) {
AbstractExternalData nodeData = nodeType.getNodeData();
if (nodeData instanceof DBMapData) {
DBMapData dbMapData = (DBMapData) nodeData;
for (InputTable input : dbMapData.getInputTables()) {
if (input.getName().equals(oldValue) || input.getTableName().equals(oldValue)) {
input.setName(newValue);
input.setTableName(newValue);
}
}
for (OutputTable output : dbMapData.getOutputTables()) {
List<DBMapperTableEntry> entries = output.getDBMapperTableEntries();
for (DBMapperTableEntry entry : entries) {
String expression = entry.getExpression();
if (expression != null && !"".equals(expression.trim())) {
//$NON-NLS-1$
//$NON-NLS-1$
int index = expression.lastIndexOf(".");
// at least "a.b"
if (index > 0) {
String connectionName = expression.substring(0, index);
if (oldValue.equals(connectionName)) {
entry.setExpression(newValue + expression.substring(index, expression.length()));
}
}
}
}
}
}
}
Aggregations