use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdi-studio-se by Talend.
the class ExportItemWizardPage method checkElement.
private void checkElement(Object obj, Set<Object> nodes) {
if (obj == null) {
return;
}
if (obj instanceof RepositoryNode) {
Object repositoryNode = null;
RepositoryNode node = (RepositoryNode) obj;
ERepositoryObjectType objectType = node.getObjectType();
Property property = null;
if (objectType != null) {
if (objectType == ERepositoryObjectType.METADATA_CON_TABLE || objectType == ERepositoryObjectType.METADATA_CON_VIEW || objectType == ERepositoryObjectType.METADATA_CON_SYNONYM || objectType == ERepositoryObjectType.METADATA_CON_QUERY) {
if (node.getObject() != null) {
property = node.getObject().getProperty();
}
} else if (objectType == ERepositoryObjectType.METADATA_CON_COLUMN) {
if (node.getObject() != null && (node.getObject() instanceof MetadataColumnRepositoryObject)) {
IRepositoryViewObject viewObj = ((MetadataColumnRepositoryObject) node.getObject()).getViewObject();
if (viewObj != null) {
property = viewObj.getProperty();
}
}
}
}
if (property != null) {
repositoryNode = RepositoryNodeUtilities.getRepositoryNode(property.getId(), false);
if (repositoryNode != null) {
nodes.add(repositoryNode);
}
} else {
nodes.add(node);
}
} else {
nodes.add(obj);
}
}
use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdi-studio-se by Talend.
the class GenericDragAndDropHandler method isValid.
private boolean isValid(RepositoryNode seletetedNode, IComponent component) {
// TUP-4151
IRepositoryViewObject object = seletetedNode.getObject();
if (component == null || object == null) {
return false;
}
ComponentProperties currentComponentProperties = null;
if (object instanceof RepositoryViewObject) {
RepositoryViewObject repositoryViewObj = (RepositoryViewObject) object;
Connection connection = ((ConnectionItem) repositoryViewObj.getProperty().getItem()).getConnection();
if (canHandle(connection)) {
GenericConnection genericConnection = (GenericConnection) connection;
currentComponentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(genericConnection.getCompProperties(), connection);
}
} else if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject metaTableRepObj = (MetadataTableRepositoryObject) object;
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(metaTableRepObj);
} else if (object instanceof MetadataColumnRepositoryObject) {
MetadataColumnRepositoryObject metaColumnRepObj = (MetadataColumnRepositoryObject) object;
ModelElement element = metaColumnRepObj.getTdColumn();
if (element != null && element.eContainer() instanceof MetadataTable) {
MetadataTable metadataTable = (MetadataTable) element.eContainer();
IMetadataTable newTable = MetadataToolHelper.convert(metadataTable);
currentComponentProperties = SchemaUtils.getCurrentComponentProperties(newTable);
}
}
if (currentComponentProperties != null) {
try {
List<ComponentDefinition> possibleComponents = ComponentsUtils.getComponentService().getPossibleComponents(currentComponentProperties);
if (component instanceof Component) {
ComponentDefinition componentDefinition = ((Component) component).getComponentDefinition();
return possibleComponents.contains(componentDefinition);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
return false;
}
use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method getColumnOwner.
public static ColumnSet getColumnOwner(RepositoryNode node) {
if (node == null) {
return null;
}
MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
TdColumn column = ((TdColumn) columnObject.getTdColumn());
if (column != null && column.eIsProxy()) {
column = (TdColumn) EObjectHelper.resolveObject(column);
}
return ColumnHelper.getColumnOwnerAsColumnSet(column);
}
use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject 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.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method createMetadataColumnRepNode.
/**
* create a temp RepNode there is a lack of parent attribute
*
* @param findColumn
*/
private static DBColumnRepNode createMetadataColumnRepNode(TdColumn findColumn, IRepositoryViewObject lastVersion) {
MetadataColumnRepositoryObject metadataColumn = new MetadataColumnRepositoryObject(lastVersion, findColumn);
metadataColumn.setId(findColumn.getName());
metadataColumn.setLabel(findColumn.getName());
DBColumnRepNode columnNode = new DBColumnRepNode(metadataColumn, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
columnNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
columnNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
metadataColumn.setRepositoryNode(columnNode);
return columnNode;
}
Aggregations