use of org.talend.core.model.metadata.MetadataXmlElementType in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method getAllColumnNodes.
/**
* get All the Column level Nodes.
*
* @param selectedNodes
* @return
*/
public static IRepositoryNode[] getAllColumnNodes(Object[] selectedNodes) {
List<IRepositoryNode> list = new ArrayList<IRepositoryNode>();
if (selectedNodes == null || selectedNodes.length == 0) {
return list.toArray(new IRepositoryNode[list.size()]);
}
Object firstElement = selectedNodes[0];
if (firstElement instanceof IRepositoryNode) {
IRepositoryNode repNode = (IRepositoryNode) firstElement;
IRepositoryViewObject repViewObject = repNode.getObject();
if (repViewObject instanceof MetadataColumnRepositoryObject || repViewObject instanceof MetadataXmlElementType) {
IRepositoryNode[] column = new IRepositoryNode[selectedNodes.length];
for (int i = 0; i < selectedNodes.length; i++) {
column[i] = (IRepositoryNode) selectedNodes[i];
}
return column;
} else if (repViewObject instanceof MetadataTableRepositoryObject) {
for (Object currentObj : selectedNodes) {
IRepositoryNode columnSetNode = (IRepositoryNode) currentObj;
List<IRepositoryNode> children = columnSetNode.getChildren();
if (children.size() > 0) {
list.addAll(children.get(0).getChildren());
}
}
return list.toArray(new IRepositoryNode[list.size()]);
}
} else if (firstElement instanceof TdTable) {
TdTable table = (TdTable) firstElement;
EList<MetadataColumn> columns = table.getColumns();
for (MetadataColumn column : columns) {
RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
list.add(recursiveFind);
}
return list.toArray(new IRepositoryNode[list.size()]);
} else if (firstElement instanceof WhereRuleChartDataEntity) {
// ADD msjian 2012-2-9 TDQ-4470: get columns from the join conditions
EList<JoinElement> joinConditions = ((WhereRuleChartDataEntity) firstElement).getIndicator().getJoinConditions();
if (joinConditions != null && joinConditions.size() > 0) {
JoinElement joinElement = joinConditions.get(0);
list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColA()));
list.add(RepositoryNodeHelper.recursiveFind(joinElement.getColB()));
return list.toArray(new IRepositoryNode[list.size()]);
}
// TDQ-4470 ~
} else if (firstElement instanceof TdView) {
// Added yyin 20120522 TDQ-4945, support tdView
TdView view = (TdView) firstElement;
EList<MetadataColumn> columns = view.getColumns();
for (MetadataColumn column : columns) {
RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(column);
list.add(recursiveFind);
}
return list.toArray(new IRepositoryNode[list.size()]);
}
// ~
return null;
}
use of org.talend.core.model.metadata.MetadataXmlElementType in project tdq-studio-se by Talend.
the class MatchAnalysisAction method getColumns.
protected IRepositoryNode[] getColumns() {
List<IRepositoryNode> list = new ArrayList<IRepositoryNode>();
Object firstElement = getSelection().getFirstElement();
if (firstElement instanceof IRepositoryNode) {
IRepositoryNode repNode = (IRepositoryNode) firstElement;
IRepositoryViewObject repViewObject = repNode.getObject();
if (repViewObject instanceof MetadataColumnRepositoryObject || repViewObject instanceof MetadataXmlElementType) {
IRepositoryNode[] column = new IRepositoryNode[getSelection().size()];
for (int i = 0; i < getSelection().size(); i++) {
column[i] = (IRepositoryNode) getSelection().toArray()[i];
}
return column;
} else if (repViewObject instanceof MetadataTableRepositoryObject) {
Object[] selections = getSelection().toArray();
for (Object currentObj : selections) {
IRepositoryNode columnSetNode = (IRepositoryNode) currentObj;
List<IRepositoryNode> children = columnSetNode.getChildren();
if (children.size() > 0) {
list.addAll(children.get(0).getChildren());
}
}
return list.toArray(new IRepositoryNode[list.size()]);
}
}
return null;
}
Aggregations