use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdi-studio-se by Talend.
the class ComponentChooseDialog method getSAPCommand.
/**
* Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
*
* @param object
* @param connectionItem
* @param table
* @param node
* @return
*/
private void getSAPCommand(CompoundCommand cc, IRepositoryViewObject object, ConnectionItem connectionItem, MetadataTable table, Node node) {
SAPFunctionUnit functionUnit = null;
if (object instanceof MetadataTableRepositoryObject) {
IElementParameter schemaParam = null;
List<IElementParameter> schemaTypeList = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
for (IElementParameter param : schemaTypeList) {
if (param.getName().equals("SCHEMA")) {
//$NON-NLS-1$
schemaParam = param;
break;
}
}
if (table.eContainer() instanceof SAPFunctionUnit) {
// function parameter table
functionUnit = (SAPFunctionUnit) table.eContainer();
// To judge what the current node is, tSAPOutput or tSAPInput component.
String sapComponentName = node.getComponent().getName();
if ("tSAPBapi".equals(sapComponentName)) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, (SAPFunctionUnit) table.eContainer(), ConvertionHelper.convert(table), null);
cc.add(command);
} else {
if (schemaParam != null) {
// repository id should be connectionid - sapfunctionName/type/tableName
String type = table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
String value = connectionItem.getProperty().getId() + " - " + functionUnit.getLabel() + "/" + type + "/" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection());
cc.add(changeValueCmd);
}
IElementParameter schemasParam = node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
if (schemasParam != null) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, table.getLabel(), ConvertionHelper.convert(table), functionUnit);
cc.add(sapCmd);
}
}
} else {
// Sap Table : keep repository id as before
if (schemaParam != null) {
//$NON-NLS-1$
String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
RepositoryChangeMetadataCommand changeValueCmd = new RepositoryChangeMetadataCommand(node, //$NON-NLS-1$
schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, ConvertionHelper.convert(table), null, connectionItem.getConnection(), table);
cc.add(changeValueCmd);
}
}
} else if (object instanceof SAPFunctionRepositoryObject) {
functionUnit = (SAPFunctionUnit) ((SAPFunctionRepositoryObject) object).getAbstractMetadataObject();
if (node.getComponent() != null && node.getComponent().getName().equals("tSAPBapi")) {
//$NON-NLS-1$
RepositoryChangeMetadataForSAPBapi command = new RepositoryChangeMetadataForSAPBapi(node, functionUnit, null, null);
cc.add(command);
} else {
for (MetadataTable metadataTable : functionUnit.getTables()) {
Command sapCmd = new RepositoryChangeMetadataForSAPCommand(node, ISAPConstant.TABLE_SCHEMAS, metadataTable.getLabel(), ConvertionHelper.convert(metadataTable), functionUnit);
cc.add(sapCmd);
}
}
}
}
use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdi-studio-se by Talend.
the class TalendDndHelper method filterNeededComponents.
public static List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(item, type);
List<IComponent> neededComponents = new ArrayList<IComponent>();
if (name == null) {
return neededComponents;
}
String productNameWanted = filterProductNameWanted(name, item);
boolean hl7Related = false;
boolean hl7Output = false;
if (item instanceof HL7ConnectionItem) {
hl7Related = true;
EList list = ((HL7Connection) ((HL7ConnectionItem) item).getConnection()).getRoot();
if (list != null && list.size() > 0) {
hl7Output = true;
}
}
// for mdm
MdmConceptType mdmType = null;
if (item instanceof MDMConnectionItem) {
MDMConnectionItem mdmItem = (MDMConnectionItem) item;
if (seletetedNode != null && seletetedNode.getObject() instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) seletetedNode.getObject();
if (mdmItem.getConnection() instanceof MDMConnection) {
MDMConnection connection = (MDMConnection) mdmItem.getConnection();
for (Object obj : connection.getSchemas()) {
if (obj instanceof Concept && object.getLabel().equals(((Concept) obj).getLabel())) {
mdmType = ((Concept) obj).getConceptType();
}
}
}
}
}
Set<IComponent> components = ComponentsFactoryProvider.getInstance().getComponents();
EmfComponent emfComponent = null;
for (IComponent component : components) {
if (component instanceof EmfComponent) {
emfComponent = (EmfComponent) component;
String componentProductname = emfComponent.getRepositoryType();
boolean value = true;
if (type == ERepositoryObjectType.METADATA_CON_TABLE) {
if (emfComponent.getName().toUpperCase().endsWith(MAP)) {
value = false;
}
}
if (hl7Output && !component.getName().equals("tHL7Output")) {
//$NON-NLS-1$
value = false;
} else if (hl7Related && !hl7Output && !component.getName().equals("tHL7Input")) {
//$NON-NLS-N$ bug15632
value = false;
}
boolean flag = filterComponent(component, name, type);
if (((componentProductname != null && productNameWanted.endsWith(componentProductname)) && value) || flag) {
Pattern pattern = Pattern.compile("^.*oracle.*$", Pattern.CASE_INSENSITIVE);
if (pattern.matcher(name.getDBType()).matches() && (emfComponent.getName().equals("tAmazonOracleInput") || emfComponent.getName().equals("tAmazonOracleOutput"))) {
continue;
}
if (item instanceof MDMConnectionItem) {
if (MdmConceptType.INPUT.equals(mdmType) && emfComponent.getName().endsWith(INPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.OUTPUT.equals(mdmType) && emfComponent.getName().endsWith(OUTPUT)) {
neededComponents.add(emfComponent);
} else if (MdmConceptType.RECEIVE.equals(mdmType) && emfComponent.getName().endsWith(RECEIVE)) {
neededComponents.add(emfComponent);
}
} else {
neededComponents.add(emfComponent);
}
}
}
}
return sortFilteredComponnents(item, seletetedNode, type, neededComponents);
}
use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdi-studio-se by Talend.
the class ComponentChooseDialog method setSAPSpecailValueForCommand.
private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
// Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
// Table node, if so, set up the table name to command.
IRepositoryViewObject object = selectedNode.getObject();
if (object instanceof MetadataColumnRepositoryObject) {
object = selectedNode.getParent().getParent().getObject();
}
SAPFunctionUnit unit = null;
if (object != null) {
if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
command.setSapFunctionLabel(unit.getLabel());
// set table name to functionName/type/tablename;
String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
command.setCurrentTableName(currentTableName);
} else if (abstractMetadataObject instanceof SAPTable) {
command.setCurrentTableName(abstractMetadataObject.getLabel());
}
} else if (object instanceof SAPFunctionRepositoryObject) {
SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
unit = sapObj.getModelElement();
command.setSapFunctionLabel(unit.getLabel());
} else if (object instanceof SAPIDocRepositoryObject) {
SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
command.setSapIDocLabel(sapObj.getLabel());
}
}
}
use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdq-studio-se by Talend.
the class OverviewResultPage method wapperInput.
/**
* DOC klliu Comment method "wapperInput". relations
*
* @param indicatorTableList
* @param parentNode
* @return
*/
private List<OverviewIndUIElement> wapperInput(EList<TableIndicator> indicatorTableList, IRepositoryNode parentNode) {
List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
List<IRepositoryNode> children = parentNode.getChildren();
for (IRepositoryNode folderNode : children) {
if (folderNode instanceof DBTableFolderRepNode) {
List<IRepositoryNode> tableNodes = folderNode.getChildren();
// MOD 20120315 klliu&yyin TDQ-2391, avoid getting many times for table nodes.
for (TableIndicator indicator : indicatorTableList) {
boolean equals = false;
for (IRepositoryNode tableNode : tableNodes) {
MetadataTable table = ((MetadataTableRepositoryObject) tableNode.getObject()).getTable();
String name = table.getName();
String tableName = indicator.getTableName();
// String connUuid = ResourceHelper.getUUID(table);
// String anaUuid = ResourceHelper.getUUID(indicator.getAnalyzedElement());
equals = name.equals(tableName);
if (equals) {
OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
tableUIEle.setNode(tableNode);
tableUIEle.setOverviewIndicator(indicator);
if (DqRepositoryViewService.isComeFromRefrenceProject(getTdDataProvider()) && ColumnSetHelper.getColumns((ColumnSet) table).isEmpty()) {
tableUIEle.setVirtualNode(true);
}
cataUIEleList.add(tableUIEle);
break;
}
}
if (!equals) {
OverviewIndUIElement tableUIEle = new OverviewIndUIElement();
tableUIEle.setOverviewIndicator(indicator);
tableUIEle.setVirtualNode(true);
cataUIEleList.add(tableUIEle);
}
}
}
}
return cataUIEleList;
}
use of org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method canDrop.
@Override
public boolean canDrop(IRepositoryNode metadataRepositoryNode) {
IRepositoryViewObject metadataRepObject = metadataRepositoryNode.getObject();
ConnectionItem connItem = (ConnectionItem) metadataRepObject.getProperty().getItem();
// MOD qiongli 2010-8-19,bug 14436:could not come from diffrent connection
Connection tdProvider = connItem.getConnection();
if (tdProvider == null) {
return false;
} else if (this.getAnalysis().getContext().getConnection() != null && !ResourceHelper.areSame(tdProvider, this.getAnalysis().getContext().getConnection())) {
return false;
}
// MOD mzhao, 2010-07-23 bug 14014: If the editor is dirty, save it firstly before drag and drop an elements.
if (masterPage.isDirty()) {
masterPage.doSave(new NullProgressMonitor());
return false;
}
List<ModelElement> existModelElements = new ArrayList<ModelElement>();
for (ModelElementIndicator modelElementIndicator : this.getAllTheElementIndicator()) {
ModelElement me = RepositoryNodeHelper.getModelElementFromRepositoryNode(modelElementIndicator.getModelElementRepositoryNode());
existModelElements.add(me);
}
// MOD mzhao 9848 2010-01-14, allowing to drag and drop table.
if (metadataRepObject instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableRepObject = (MetadataTableRepositoryObject) metadataRepObject;
return !existModelElements.containsAll(ColumnSetHelper.getColumns((TdTable) tableRepObject.getTable()));
}
if (metadataRepObject instanceof MetadataColumnRepositoryObject) {
if (existModelElements.contains(((MetadataColumnRepositoryObject) metadataRepObject).getTdColumn())) {
return false;
}
}
if (metadataRepObject instanceof MetadataXmlElementTypeRepositoryObject) {
return !metadataRepositoryNode.hasChildren();
}
return true;
}
Aggregations