use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class SapSchemaTypeController method createComboCommand.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createComboCommand(org
* .eclipse.swt.custom.CCombo)
*/
@Override
protected Command createComboCommand(CCombo combo) {
IMetadataTable repositoryMetadata = null;
String fullParamName = (String) combo.getData(PARAMETER_NAME);
IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
//$NON-NLS-1$
String value = new String("");
IElementParameter param = elem.getElementParameter(fullParamName);
for (int j = 0; j < param.getListItemsValue().length; j++) {
if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
value = (String) param.getListItemsValue()[j];
}
}
// if change to build-in, unuse the validation rule if the component has.
boolean isValRulesLost = false;
IRepositoryViewObject currentValRuleObj = ValidationRulesUtil.getCurrentValidationRuleObjs(elem);
if (value.equals(EmfComponent.BUILTIN) && currentValRuleObj != null) {
if (!MessageDialog.openConfirm(combo.getShell(), //$NON-NLS-1$
Messages.getString("SchemaTypeController.validationrule.title.confirm"), Messages.getString("SchemaTypeController.validationrule.selectBuildInMsg"))) {
//$NON-NLS-1$
return null;
} else {
isValRulesLost = true;
}
}
org.talend.core.model.metadata.builder.connection.Connection connection = null;
if (elem instanceof Node) {
Node node = (Node) elem;
Command baseCommand = null;
boolean isReadOnly = false;
String newRepositoryIdValue = null;
if (node.getMetadataFromConnector(param.getContext()) != null) {
isReadOnly = node.getMetadataFromConnector(param.getContext()).isReadOnly();
}
if (//$NON-NLS-1$
value.equals(EmfComponent.BUILTIN) && isReadOnly && !"tLogCatcher".equals(node.getComponent().getName()) && !"tStatCatcher".equals(node.getComponent().getName())) {
//$NON-NLS-1$
boolean hasMetadataInput = false;
if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0) {
hasMetadataInput = true;
}
repositoryMetadata = new MetadataTable();
if (hasMetadataInput) {
for (Connection connec : (List<Connection>) node.getIncomingConnections()) {
if (connec.isActivate() && (connec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connec.getLineStyle().equals(EConnectionType.TABLE))) {
repositoryMetadata = connec.getMetadataTable().clone();
}
}
}
} else if (value.equals(EmfComponent.REPOSITORY)) {
// Map<String, IMetadataTable> repositoryTableMap = dynamicProperty.getRepositoryTableMap();
IElementParameter property = ((Node) elem).getElementParameter(EParameterName.PROPERTY_TYPE.getName());
if ((property != null) && EmfComponent.REPOSITORY.equals(property.getValue())) {
String propertySelected = (String) ((Node) elem).getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).getValue();
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
/* 16969 */
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(propertySelected);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
// item = factory.getLastVersion(propertySelected).getProperty().getItem();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
final ConnectionItem connectionItem = (ConnectionItem) item;
if (connectionItem != null) {
connection = connectionItem.getConnection();
}
}
}
IElementParameter repositorySchemaType = param.getParentParameter().getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
String schemaSelected = (String) repositorySchemaType.getValue();
/* value can be devided means the value like "connectionid - label" */
//$NON-NLS-1$
String[] keySplitValues = schemaSelected.toString().split(" - ");
if (keySplitValues.length > 1) {
String connectionId = keySplitValues[0];
String tableLabel = keySplitValues[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property tmpproperty = repobj.getProperty();
if (tmpproperty != null) {
item = tmpproperty.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
final ConnectionItem connectionItem = (ConnectionItem) item;
if (connectionItem != null) {
connection = connectionItem.getConnection();
}
}
if (item != null && item instanceof ConnectionItem) {
boolean findTable = false;
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
repositoryMetadata = ConvertionHelper.convert(table);
newRepositoryIdValue = schemaSelected;
findTable = true;
break;
}
}
if (!findTable) {
repositoryMetadata = new MetadataTable();
}
} else {
repositoryMetadata = new MetadataTable();
}
} else {
// value only got a empty string
repositoryMetadata = new MetadataTable();
}
/* see bug 16969 */
// if (repositoryTableMap.containsKey(schemaSelected)) {
// repositoryMetadata = repositoryTableMap.get(schemaSelected);
// // bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
// newRepositoryIdValue = schemaSelected;// + " - " + repositoryMetadata.getLabel();
// } else {
// if (repositoryTableMap.keySet().size() == 0) {
// repositoryMetadata = new MetadataTable();
// } else {
// newRepositoryIdValue = repositoryTableMap.keySet().iterator().next();
// // Gets the schema of the first item in repository schema type combo.
// repositoryMetadata = repositoryTableMap.get(newRepositoryIdValue);
// // bug 6028, Display the parameter of REPOSITORY_SCHEMA_TYPE
// // newRepositoryIdValue = newRepositoryIdValue + " - " + repositoryMetadata.getLabel();
// }
// }
} else {
baseCommand = new PropertyChangeCommand(elem, fullParamName, value);
}
if (switchParam != null) {
switchParam.setValue(Boolean.FALSE);
}
CompoundCommand cc = new CompoundCommand();
if (baseCommand != null) {
cc.add(baseCommand);
} else {
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) elem, fullParamName, value, repositoryMetadata, newRepositoryIdValue, null);
changeMetadataCommand.setConnection(connection);
cc.add(changeMetadataCommand);
}
// unuse the validation rules of the component.
if (isValRulesLost) {
ValidationRulesUtil.appendRemoveValidationRuleCommands(cc, elem);
}
return cc;
}
return null;
}
use of org.talend.core.model.metadata.MetadataTable in project tdq-studio-se by Talend.
the class ModelElementEditonDistance method distance.
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.compare.match.eobject.EditionDistance#distance(org.eclipse.emf.compare.Comparison,
* org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EObject)
*/
@Override
public double distance(Comparison inProgress, EObject a, EObject b) {
boolean isSame = false;
if (a instanceof DatabaseConnection) {
return 0;
}
if (a instanceof Catalog && b instanceof Catalog) {
Catalog catalog1 = (Catalog) a;
Catalog catalog2 = (Catalog) b;
isSame = StringUtils.equalsIgnoreCase(catalog1.getName(), catalog2.getName());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof Schema && b instanceof Schema) {
Schema schema1 = (Schema) a;
Schema schema2 = (Schema) b;
isSame = StringUtils.equalsIgnoreCase(schema1.getName(), schema2.getName());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TdTable && b instanceof TdTable) {
TdTable tdTable1 = (TdTable) a;
TdTable tdTable2 = (TdTable) b;
isSame = StringUtils.equalsIgnoreCase(tdTable1.getName(), tdTable2.getName());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TdView && b instanceof TdView) {
TdView tdView1 = (TdView) a;
TdView tdView2 = (TdView) b;
isSame = StringUtils.equalsIgnoreCase(tdView1.getName(), tdView2.getName());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TdColumn && b instanceof TdColumn) {
TdColumn tdColumn1 = (TdColumn) a;
TdColumn tdColumn2 = (TdColumn) b;
isSame = StringUtils.equalsIgnoreCase(tdColumn1.getName(), tdColumn2.getName()) && distance(inProgress, tdColumn1.getSqlDataType(), tdColumn2.getSqlDataType()) == 0;
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TaggedValue && b instanceof TaggedValue) {
TaggedValue taggedValue1 = (TaggedValue) a;
TaggedValue taggedValue2 = (TaggedValue) b;
isSame = StringUtils.equalsIgnoreCase(taggedValue1.getTag(), taggedValue2.getTag()) && StringUtils.equalsIgnoreCase(taggedValue1.getValue(), taggedValue2.getValue());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TdExpression && b instanceof TdExpression) {
TdExpression tdExpression1 = (TdExpression) a;
TdExpression tdExpression2 = (TdExpression) b;
isSame = StringUtils.equalsIgnoreCase(tdExpression1.getLanguage(), tdExpression2.getLanguage()) && StringUtils.equalsIgnoreCase(tdExpression1.getBody(), tdExpression2.getBody());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof TdSqlDataType && b instanceof TdSqlDataType) {
TdSqlDataType tdExpression1 = (TdSqlDataType) a;
TdSqlDataType tdExpression2 = (TdSqlDataType) b;
isSame = StringUtils.equalsIgnoreCase(tdExpression1.getName(), tdExpression2.getName());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof MetadataColumn && b instanceof MetadataColumn) {
// Added yyin TDQ-8360
MetadataColumn metaColumn1 = (MetadataColumn) a;
MetadataColumn metaColumn2 = (MetadataColumn) b;
isSame = StringUtils.equalsIgnoreCase(metaColumn1.getLabel(), metaColumn2.getLabel());
return isSame ? 0 : Double.MAX_VALUE;
} else if (a instanceof MetadataTable && b instanceof MetadataTable) {
MetadataTable mTable1 = (MetadataTable) a;
MetadataTable mTable2 = (MetadataTable) b;
isSame = StringUtils.equalsIgnoreCase(mTable1.getLabel(), mTable2.getLabel());
return isSame ? 0 : Double.MAX_VALUE;
}
return super.distance(inProgress, a, b);
}
use of org.talend.core.model.metadata.MetadataTable in project tbd-studio-se by Talend.
the class HadoopSubMultiRepTypeProcessor method selectRepositoryNode.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
* org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
*/
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (node == null || repositoryTypes == null || repositoryTypes.length == 0) {
return false;
}
ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (HadoopClusterRepositoryNodeType.HADOOPCLUSTER.equals(repObjType) && ArrayUtils.contains(repositoryTypes, "HADOOPCLUSTER")) {
// $NON-NLS-1$
return isValidAttributes(node);
}
if (node.getType() == ENodeType.SIMPLE_FOLDER || HCRepositoryUtil.isHadoopContainerNode(node)) {
return isValidFolder(node);
}
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
return true;
}
use of org.talend.core.model.metadata.MetadataTable in project tbd-studio-se by Talend.
the class UIManager method closeNeo4j.
public void closeNeo4j(int response, boolean fromDialog) {
setNeo4jResponse(response);
Composite parent = neo4jUI.getNeo4jUIParent();
saveCurrentUiProperties();
MetadataTable table = (MetadataTable) neo4jManager.getNeo4jComponent().getMetadataList().get(0);
boolean hasColumns = (table != null) && (table.getListColumns() != null && table.getListColumns().size() != 0);
List<Map<String, Object>> originalValuesDataList = neo4jManager.getNeo4jComponent().getOriginalValuesList();
List<Map<String, Object>> currentValuesDataList = getNewValuesList();
boolean valuesAll1 = originalValuesDataList.containsAll(currentValuesDataList);
boolean valuesAll2 = currentValuesDataList.containsAll(originalValuesDataList);
List<Map<String, Object>> originalIndexesDataList = neo4jManager.getNeo4jComponent().getOriginalIndexesList();
List<Map<String, Object>> currentIndexesDataList = getNewIndexesList();
boolean indexesAll1 = originalIndexesDataList.containsAll(currentIndexesDataList);
boolean indexesAll2 = currentIndexesDataList.containsAll(originalIndexesDataList);
List<Map<String, Object>> originalRelationshipsDataList = neo4jManager.getNeo4jComponent().getOriginalRelationshipsList();
List<Map<String, Object>> currentRelationshipsDataList = getNewRelationShipsList();
boolean relationshipsAll1 = originalRelationshipsDataList.containsAll(currentRelationshipsDataList);
boolean relationshipsAll2 = currentRelationshipsDataList.containsAll(originalRelationshipsDataList);
boolean containsAll = valuesAll1 && valuesAll2 && indexesAll1 && indexesAll2 & relationshipsAll1 & relationshipsAll2;
if (hasColumns && !containsAll && response == SWT.CANCEL) {
boolean isNotSaveSetting = // $NON-NLS-1$
MessageDialog.openQuestion(// $NON-NLS-1$
parent.getShell(), // $NON-NLS-1$
"Neo4j", "Do you want to close the Neo4j component dialog without save the current settings?");
if (isNotSaveSetting) {
saveAllData(originalValuesDataList, originalIndexesDataList, originalRelationshipsDataList);
} else {
response = SWT.OK;
setNeo4jResponse(response);
}
}
if (response == SWT.OK) {
saveAllData(currentValuesDataList, currentIndexesDataList, currentRelationshipsDataList);
}
if (parent instanceof Shell && !fromDialog) {
((Shell) parent).close();
}
}
use of org.talend.core.model.metadata.MetadataTable in project tbd-studio-se by Talend.
the class UIManager method getNewValuesList.
private List<Map<String, Object>> getNewValuesList() {
List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
MetadataTable table = (MetadataTable) neo4jManager.getNeo4jComponent().getMetadataList().get(0);
neo4jManager.convert(neo4jManager.getNeo4jComponent(), table);
for (IMetadataColumn col : table.getListColumns()) {
MetadataColumnExt ext = (MetadataColumnExt) col;
Map<String, Object> value = new HashMap<String, Object>();
value.put(Neo4jComponent.SCHEMA_COLUMN, ext.getLabel());
value.put(Neo4jComponent.AUTO_INDEXED, String.valueOf(ext.getData().isAutoIndexed()));
value.put(Neo4jComponent.INDEX_NAMES, ext.getData().inlineIndexNames());
map.add(value);
}
return map;
}
Aggregations