use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class VirtualRowGeneratorNode method getArray.
/**
* yzhang Comment method "initArray".
*/
private Object getArray() {
List<Map<String, String>> map = new ArrayList<Map<String, String>>();
MetadataTable table = (MetadataTable) this.getMetadataList().get(0);
for (IMetadataColumn col : table.getListColumns()) {
VirtualMetadataColumn ext = (VirtualMetadataColumn) col;
Map<String, String> value = new HashMap<String, String>();
value.put(RowGeneratorComponent.COLUMN_NAME, ext.getLabel());
List<Variable> variables = ExpressionBuilderDialog.getTestComposite().getVariableList();
String expression = ExpressionBuilderDialog.getExpressionComposite().getExpression();
// modify for bug 9471
try {
for (Variable varible : variables) {
if (valueContains(expression, varible.getName())) {
Integer.parseInt(varible.getValue());
}
}
for (Variable var : variables) {
String talendType = var.getTalendType();
JavaType javaTypeFromId = JavaTypesManager.getJavaTypeFromId(talendType);
String label = null;
String value2 = var.getValue();
if (javaTypeFromId != null) {
label = javaTypeFromId.getLabel();
if ("BigDecimal".equals(label)) {
//$NON-NLS-1$
//$NON-NLS-1$//$NON-NLS-1$
value2 = " new BigDecimal(" + value2 + ")";
}
}
expression = renameValues(expression, var.getName(), value2);
}
} catch (NumberFormatException e1) {
for (Variable var : variables) {
//$NON-NLS-1$ //$NON-NLS-2$
expression = renameValues(expression, var.getName(), "\"" + var.getValue() + "\"");
}
}
//$NON-NLS-1$//$NON-NLS-1$
value.put(RowGeneratorComponent.ARRAY, "\"\"+(" + expression + ")+\"\"");
map.add(value);
}
return map;
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class RepositoryTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null) {
return false;
}
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
// for sub folders
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
// for Db Connections
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
// }
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;
}
if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
// tAdvancedFileOutputXML
if (repositoryType != null && repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
if (connection instanceof XmlFileConnection && ((XmlFileConnection) connection).isInputModel()) {
return false;
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
//$NON-NLS-1$
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
if (repositoryType.contains(":")) {
// database //$NON-NLS-1$
// is
// specified
// //$NON-NLS-1$
//$NON-NLS-1$
String neededDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (hidenTypeSelection) {
return true;
}
if (!MetadataTalendType.sameDBProductType(neededDbType, currentDbType)) {
return false;
}
}
}
}
if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
if (item instanceof HeaderFooterConnectionItem) {
HeaderFooterConnectionItem connectionItem = (HeaderFooterConnectionItem) item;
HeaderFooterConnection connection = (HeaderFooterConnection) connectionItem.getConnection();
boolean isHeader = connection.isIsHeader();
if ((isHeader && isHeaderButton) || (!isHeader && !isHeaderButton)) {
return true;
} else {
return false;
}
}
}
return true;
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class ValidationRuleTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
ProjectManager pManager = ProjectManager.getInstance();
if (!pManager.isInCurrentMainProject(node)) {
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
if (node.getObject() == null || node.getObject().getProperty().getItem() == null) {
return false;
}
if (node.getObject() instanceof MetadataTable) {
return false;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (node.getObjectType() == getType()) {
return true;
}
return false;
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class MapperUI method prepareClosing.
public void prepareClosing(int response) {
List<IMetadataTable> newMetadatas = new ArrayList<IMetadataTable>();
EList<OutputXmlTree> outputTrees = null;
if (response == SWT.OK || response == SWT.APPLICATION_MODAL) {
// fix for bug TDI-18185
mapperManager.fireCurrentDirectEditApply();
// if press ok or apply , use copyOfMapData to check the metadata list
outputTrees = copyOfMapData.getOutputTrees();
} else {
// if press cancel , use the original mapData
outputTrees = ((XmlMapData) mapperComponent.getExternalEmfData()).getOutputTrees();
}
List<IMetadataTable> copyOfMetadata = new ArrayList<IMetadataTable>(mapperComponent.getMetadataList());
for (OutputXmlTree outputTree : outputTrees) {
IMetadataTable found = null;
for (IMetadataTable table : mapperComponent.getMetadataList()) {
if (outputTree.getName().equals(table.getTableName())) {
found = table;
}
}
if (found != null) {
newMetadatas.add(found);
} else {
// create a new metadata if needed
MetadataTable metadataTable = new MetadataTable();
metadataTable.setTableName(outputTree.getName());
mapperComponent.getProcess().addUniqueConnectionName(outputTree.getName());
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (OutputTreeNode treeNode : outputTree.getNodes()) {
MetadataColumn column = new MetadataColumn();
column.setLabel(treeNode.getName());
column.setKey(treeNode.isKey());
column.setTalendType(treeNode.getType());
column.setNullable(treeNode.isNullable());
column.setPattern(treeNode.getPattern());
listColumns.add(column);
}
metadataTable.setListColumns(listColumns);
newMetadatas.add(metadataTable);
}
}
mapperComponent.setMetadataList(newMetadatas);
copyOfMetadata.removeAll(newMetadatas);
List<IODataComponent> outputs = mapperComponent.getIODataComponents().getOuputs();
List<String> connectionNames = new ArrayList<String>();
for (IODataComponent output : outputs) {
connectionNames.add(output.getUniqueName());
}
for (IMetadataTable leftTree : copyOfMetadata) {
if (!connectionNames.contains(leftTree.getTableName())) {
mapperComponent.getProcess().removeUniqueConnectionName(leftTree.getTableName());
}
}
}
use of org.talend.core.model.metadata.MetadataTable in project tdi-studio-se by Talend.
the class RepositoryXmlSelectionDialog method isSelectionValid.
@Override
protected boolean isSelectionValid(SelectionChangedEvent event) {
boolean highlightOKButton = true;
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection == null || selection.size() != 1) {
highlightOKButton = false;
} else {
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
if (node.getObject() == null || node.getObject().getProperty() == null) {
return false;
}
if (node.getObject() instanceof Folder) {
return false;
}
Item item = node.getObject().getProperty().getItem();
if (item instanceof XmlFileConnectionItem) {
ERepositoryObjectType t = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
highlightOKButton = false;
}
} else if (item instanceof MDMConnectionItem) {
if (node.getObject() instanceof MetadataTable) {
highlightOKButton = true;
updateErrorMessage(null);
} else {
highlightOKButton = false;
updateErrorMessage(Messages.getString("RepositoryXmlSelectionDialog.UpdateErrorMessage"));
}
}
}
return highlightOKButton;
}
Aggregations