use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class MetadataEmfFacotryTest method testSetMetadataTable.
@Test
public void testSetMetadataTable() {
IMetadataTable table = new MetadataTable();
table.getAdditionalProperties().put(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE, SAPBWTableHelper.IO_INNERTYPE_ATTRIBUTE);
MetadataEmfFactory factory = new MetadataEmfFactory();
factory.setMetadataTable(table);
Object innerType = factory.getMetadataType().getAdditionalProperties().get(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE);
assertEquals(SAPBWTableHelper.IO_INNERTYPE_ATTRIBUTE, innerType);
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class NodeQueryCheckUtilTest method createSimpleMetadata.
private IMetadataTable createSimpleMetadata() {
IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
IMetadataColumn column1 = new MetadataColumn();
//$NON-NLS-1$
column1.setLabel("C1");
//$NON-NLS-1$
column1.setTalendType("id_String");
table.getListColumns().add(column1);
IMetadataColumn column2 = new MetadataColumn();
//$NON-NLS-1$
column2.setLabel("C2");
//$NON-NLS-1$
column2.setTalendType("id_String");
table.getListColumns().add(column2);
IMetadataColumn column3 = new MetadataColumn();
//$NON-NLS-1$
column3.setLabel("C3");
//$NON-NLS-1$
column3.setTalendType("id_String");
table.getListColumns().add(column3);
IMetadataColumn column4 = new MetadataColumn();
//$NON-NLS-1$
column4.setLabel("C4");
//$NON-NLS-1$
column4.setTalendType("id_String");
table.getListColumns().add(column4);
return table;
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class PostgresGenerationManagerTest method init.
private void init(String schema, String main_table, String lookup_table) {
List<IConnection> incomingConnections = new ArrayList<IConnection>();
String[] mainTableEntities = new String[] { "id", "name", "classNum" };
String[] lookupEndtities = new String[] { "id", "score" };
incomingConnections.add(mockConnection(schema, main_table, mainTableEntities));
incomingConnections.add(mockConnection(schema, lookup_table, lookupEndtities));
component.setIncomingConnections(incomingConnections);
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + main_table);
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + lookup_table);
entities = getMetadataEntities(lookupEndtities, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName("grade");
List<ExternalDbMapEntry> conditions = new ArrayList<ExternalDbMapEntry>();
conditions.add(new ExternalDbMapEntry(schema + "." + main_table + ".id =3"));
outputTable.setCustomWhereConditionsEntries(conditions);
String[] names = new String[] { "id", "name", "classNum", "score" };
String[] expressions = new String[] { schema + "." + main_table + ".id", schema + "." + main_table + ".name", schema + "." + main_table + ".classNum", schema + "." + lookup_table + ".score" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
component.setExternalData(externalData);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(names);
metadataTable.setLabel("grade");
metadataList.add(metadataTable);
component.setMetadataList(metadataList);
Process process = mock(Process.class);
when(process.getContextManager()).thenReturn(new JobContextManager());
component.setProcess(process);
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class MultiUIManager method autoMap.
/**
*
* DOC wzhang Comment method "autoMap". for multiSchema.
*/
public void autoMap() {
List<FOXTreeNode> treeData = foxManager.getTreeData(foxManager.getCurrentSchema());
if (treeData == null || treeData.size() < 1) {
return;
}
FOXTreeNode root = treeData.get(0);
List<FOXTreeNode> mappableNodes = new ArrayList<FOXTreeNode>();
getMappableNode((Element) root, mappableNodes);
IConnection connection = foxUI.getConnection();
if (connection != null) {
IMetadataTable metadataTable = connection.getMetadataTable();
if (metadataTable != null) {
List<IMetadataColumn> schemaData = metadataTable.getListColumns();
for (FOXTreeNode node : mappableNodes) {
for (IMetadataColumn column : schemaData) {
if (node.getLabel().equals(column.getLabel())) {
node.setTable(metadataTable);
node.setColumn(column);
node.setDefaultValue(null);
node.setRow(foxManager.getCurrentSchema());
break;
}
}
}
}
}
this.foxUI.refreshXMLViewer(root);
this.foxUI.redrawLinkers();
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class MultiFOXManager method initModel.
public void initModel() {
int i = 0;
List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(foxComponent, IConnectionCategory.FLOW);
for (IConnection connection : incomingConnections) {
IMetadataTable metadataTable = connection.getMetadataTable();
metadataTable.setLabel(connection.getUniqueName());
treeData = new ArrayList<FOXTreeNode>();
if (// the first schema as current
i == 0)
currentSchema = metadataTable.getLabel();
FOXTreeNode rootNode = null;
FOXTreeNode current = null;
FOXTreeNode temp = null;
FOXTreeNode mainNode = null;
String mainPath = null;
String currentPath = null;
String defaultValue = null;
int nodeOrder = 0;
boolean haveOrder = true;
//$NON-NLS-1$
String schemaId = metadataTable.getLabel() + ":";
// build root tree
List<Map<String, String>> rootTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.ROOT);
if (rootTable != null) {
for (Map<String, String> rootMap : rootTable) {
String newPath = rootMap.get(FileOutputXMLComponent.PATH);
String columnName = rootMap.get(FileOutputXMLComponent.COLUMN);
defaultValue = rootMap.get(FileOutputXMLComponent.VALUE);
String orderValue = rootMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(rootMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
//$NON-NLS-1$
String flag = columnName + ":";
if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
//$NON-NLS-1$
continue;
}
if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = addElement(current, currentPath, newPath, defaultValue);
if (rootNode == null) {
rootNode = temp;
}
if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
temp.setRow(metadataTable.getLabel());
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
//$NON-NLS-1$
columnName = columnName.replace(schemaId, "");
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
// build group tree
current = mainNode;
currentPath = mainPath;
boolean isFirst = true;
List<Map<String, String>> groupTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.GROUP);
if (groupTable != null) {
for (Map<String, String> groupMap : groupTable) {
String newPath = groupMap.get(FileOutputXMLComponent.PATH);
String columnName = groupMap.get(FileOutputXMLComponent.COLUMN);
defaultValue = groupMap.get(FileOutputXMLComponent.VALUE);
String orderValue = groupMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(groupMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
//$NON-NLS-1$
String flag = columnName + ":";
if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
//$NON-NLS-1$
continue;
}
if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
mainNode = temp;
mainPath = newPath;
}
if (isFirst) {
temp.setGroup(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
temp.setRow(metadataTable.getLabel());
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
//$NON-NLS-1$
columnName = columnName.replace(schemaId, "");
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
}
// build loop tree
current = mainNode;
currentPath = mainPath;
isFirst = true;
List<Map<String, String>> loopTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.LOOP);
if (loopTable != null) {
for (Map<String, String> loopMap : loopTable) {
String newPath = loopMap.get(FileOutputXMLComponent.PATH);
String columnName = loopMap.get(FileOutputXMLComponent.COLUMN);
defaultValue = loopMap.get(FileOutputXMLComponent.VALUE);
String orderValue = loopMap.get(FileOutputXMLComponent.ORDER);
if (orderValue == null || "".equals(orderValue)) {
haveOrder = false;
}
if (haveOrder) {
nodeOrder = Integer.valueOf(loopMap.get(FileOutputXMLComponent.ORDER)).intValue();
}
//$NON-NLS-1$
String flag = columnName + ":";
if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
//$NON-NLS-1$
continue;
}
if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
//$NON-NLS-1$
temp = new Attribute(newPath);
temp.setDefaultValue(defaultValue);
temp.setAttribute(true);
current.addChild(temp);
} else if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
//$NON-NLS-1$
temp = new NameSpaceNode(newPath);
temp.setDefaultValue(defaultValue);
temp.setNameSpace(true);
current.addChild(temp);
} else {
temp = this.addElement(current, currentPath, newPath, defaultValue);
if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
//$NON-NLS-1$
temp.setMain(true);
}
if (isFirst) {
temp.setLoop(true);
isFirst = false;
}
current = temp;
currentPath = newPath;
}
if (haveOrder) {
temp.setOrder(nodeOrder);
}
temp.setRow(metadataTable.getLabel());
if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
//$NON-NLS-1$
columnName = columnName.replace(schemaId, "");
temp.setColumn(metadataTable.getColumn(columnName));
temp.setTable(metadataTable);
}
}
if (rootNode == null) {
//$NON-NLS-1$
rootNode = new Element("rootTag");
}
rootNode.setParent(null);
if (haveOrder) {
orderNode(rootNode);
}
treeData.add(rootNode);
rootNode.setRow(metadataTable.getLabel());
contents.put(metadataTable.getLabel(), treeData);
i++;
}
}
}
Aggregations