use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.
the class DFConnectionRepNode method getDfConnection.
public DelimitedFileConnection getDfConnection() {
DelimitedFileConnection dfConnection = null;
Property property = getObject().getProperty();
Item item = property.getItem();
if (item instanceof DelimitedFileConnectionItem) {
dfConnection = (DelimitedFileConnection) ((DelimitedFileConnectionItem) item).getConnection();
}
return dfConnection;
}
use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.
the class MatchAnalysisDetailsPage method setSampleDataShowWayStatus.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#setSampleDataShowWayStatus()
*/
@Override
protected void setSampleDataShowWayStatus() {
DataManager connection = analysisHandler.getConnection();
boolean isNotSupportRandom = connection != null && (connection instanceof DelimitedFileConnection || ((connection instanceof DatabaseConnection) && (ConnectionHelper.isInformix((DatabaseConnection) connection) || ConnectionHelper.isSybase((DatabaseConnection) connection))));
sampleDataShowWayCombo.setEnabled(!isNotSupportRandom);
}
use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.
the class FileTreeLabelProvider method getImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
*/
@Override
public Image getImage(Object element) {
Image image = null;
if (element instanceof ItemRecord) {
ItemRecord record = (ItemRecord) element;
File file = record.getFile();
String fileName = file.getName();
if (file.isDirectory()) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
if (ResourceManager.getWorskpacePath().toFile().equals(file)) {
image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
} else {
EResourceConstant constant = resolveResourceConstant(fileName);
if (constant != null) {
switch(constant) {
case DATA_PROFILING:
image = ImageLib.getImage(ImageLib.DATA_PROFILING);
break;
case METADATA:
image = ImageLib.getImage(ImageLib.METADATA);
break;
case LIBRARIES:
image = ImageLib.getImage(ImageLib.LIBRARIES);
break;
case ANALYSIS:
break;
case REPORTS:
break;
case EXCHANGE:
image = ImageLib.getImage(ImageLib.EXCHANGE);
break;
case DB_CONNECTIONS:
image = ImageLib.getImage(ImageLib.CONNECTION);
break;
case FILEDELIMITED:
image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
break;
case HADOOP_CLUSTER:
image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
break;
case CONTEXT:
image = ImageLib.getImage(ImageLib.CONTEXT);
break;
default:
break;
}
}
}
} else {
if (fileName.endsWith(FactoriesUtil.ANA)) {
image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
} else if (fileName.endsWith(FactoriesUtil.REP)) {
image = ImageLib.getImage(ImageLib.REPORT_OBJECT);
} else if (fileName.endsWith(FactoriesUtil.PATTERN)) {
image = ImageLib.getImage(ImageLib.PATTERN_REG);
} else if (fileName.endsWith(FactoriesUtil.DQRULE)) {
if (record.getElement() instanceof MatchRuleDefinition) {
image = ImageLib.getImage(ImageLib.MATCH_RULE_ICON);
} else {
image = ImageLib.getImage(ImageLib.DQ_RULE);
}
} else if (fileName.endsWith(FactoriesUtil.ITEM_EXTENSION)) {
if (record.getElement() instanceof DelimitedFileConnection) {
image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
} else if (record.getElement() instanceof DatabaseConnection) {
image = ImageProvider.getImage(ECoreImage.METADATA_CONNECTION_ICON);
} else {
image = ImageLib.getImage(ImageLib.CONTEXT);
}
} else if (fileName.endsWith(FactoriesUtil.DEFINITION)) {
image = ImageLib.getImage(ImageLib.IND_DEFINITION);
} else if (fileName.endsWith(FactoriesUtil.SQL)) {
image = ImageLib.getImage(ImageLib.SOURCE_FILE);
} else if (fileName.endsWith(FactoriesUtil.JAR)) {
image = ImageLib.getImage(ImageLib.JAR_FILE);
} else if (fileName.endsWith(FactoriesUtil.JRXML)) {
image = ImageLib.getImage(ImageLib.JRXML_ICON);
}
}
}
return image != null ? image : super.getImage(element);
}
use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.
the class RespositoryDetailView method selectionChanged.
/*
* (non-Javadoc)
*
* @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
clearContainer();
boolean isNeedcreateDefault = true;
try {
if (part instanceof DQRespositoryView) {
StructuredSelection sel = (StructuredSelection) selection;
// MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
Object fe = sel.getFirstElement();
// MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
fe = ((IRepositoryNode) fe).getObject();
}
if (fe instanceof IFile) {
IFile fe2 = (IFile) fe;
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
} else if (fe instanceof IRepositoryViewObject) {
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
} else if (fe instanceof DBConnectionRepNode) {
DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
// MOD sizhaoliu TDQ-6316
ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
createDataProviderDetail(connectionItem);
isNeedcreateDefault = false;
} else if (fe instanceof DBCatalogRepNode) {
DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
Catalog catalog = catalogNode.getCatalog();
createTdCatalogDetail(catalog);
isNeedcreateDefault = false;
} else if (fe instanceof DBSchemaRepNode) {
DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
Schema schema = schemaNode.getSchema();
createTdSchemaDetail(schema);
isNeedcreateDefault = false;
} else if (fe instanceof DBTableRepNode) {
DBTableRepNode tableNode = (DBTableRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
tableNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
TdTable tdTable = tableNode.getTdTable();
createTableDetail(tdTable);
isNeedcreateDefault = false;
} else if (fe instanceof DBViewRepNode) {
DBViewRepNode viewNode = (DBViewRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
viewNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
createNameCommentDetail(viewNode.getTdView());
isNeedcreateDefault = false;
} else if (fe instanceof DBColumnRepNode) {
DBColumnRepNode columnNode = (DBColumnRepNode) fe;
TdColumn column = columnNode.getTdColumn();
createTdColumn(column);
isNeedcreateDefault = false;
} else if (fe instanceof IEcosComponent) {
IEcosComponent component = (IEcosComponent) fe;
createEcosComponent(component);
isNeedcreateDefault = false;
} else if (fe instanceof RegularExpression) {
// MOD mzhao 2009-04-20,Bug 6349.
RegularExpression regularExpression = (RegularExpression) fe;
createRegularExpression(regularExpression);
isNeedcreateDefault = false;
} else if (fe instanceof PatternLanguageRepNode) {
// MOD mzhao 2012-08-15,feature TDQ-4037.
PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
createRegularExpression(pattLangNode.getRegularExpression());
isNeedcreateDefault = false;
} else if (fe instanceof SourceFileRepNode) {
// MOD klliu 2001-02-28 bug 19154
IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
DQRepositoryNode node = (DQRepositoryNode) fe;
IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
createSqlFileDetail(file);
} else if (fe instanceof ExchangeComponentRepNode) {
// MOD klliu 2001-02-28 bug 19154
IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
IEcosComponent component = ecosComponent;
createEcosComponent(component);
isNeedcreateDefault = false;
// ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
} else if (fe instanceof DFConnectionRepNode) {
DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
DelimitedFileConnection dfConnection = dfNode.getDfConnection();
createDFconnectionName(dfNode.getObject().getLabel());
createDataProviderDetail(dfConnection);
isNeedcreateDefault = false;
}
if (PluginChecker.isTDQLoaded()) {
if (fe instanceof EObject) {
createTechnicalDetail((EObject) fe);
} else if (fe instanceof IFile) {
createTechnicalDetail((IFile) fe);
} else if (fe instanceof IRepositoryViewObject) {
createTechnicalDetail((IRepositoryViewObject) fe);
} else {
createExtDefault();
}
}
if (!scomp.isDisposed()) {
scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
composite.layout();
}
} else if (part instanceof CommonFormEditor) {
CommonFormEditor editor = (CommonFormEditor) part;
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) editorInput;
IFile file = input.getFile();
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
}
}
if (isNeedcreateDefault) {
createDefault();
}
// feature 19053
if (!gContainer.isDisposed()) {
gContainer.layout();
if (tContainer != null) {
tContainer.layout();
}
}
} catch (MissingDriverException e) {
if (PluginChecker.isOnlyTopLoaded()) {
MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
} else {
log.error(e, e);
}
}
}
use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.
the class FileCSVReaderTest method testNext.
/**
* Test method for {@link org.talend.cwm.db.connection.file.FileCSVReader#next()}.
*/
@Test
public void testNext() {
try {
File file = new File("./file.txt");
if (file.exists()) {
file.delete();
}
if (file.createNewFile()) {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
out.println("id,name,email");
out.println("1,tom,a@b.cn");
out.println("2,jerry,x@b.cn");
out.println("3,bob,top@b.cn");
out.close();
DelimitedFileConnection delimitedFileconnection = ConnectionFactory.eINSTANCE.createDelimitedFileConnection();
delimitedFileconnection.setFilePath(file.getAbsolutePath());
delimitedFileconnection.setLimitValue("0");
delimitedFileconnection.setHeaderValue("1");
delimitedFileconnection.setFieldSeparatorValue(",");
List<ModelElement> analysisElementList = new ArrayList<ModelElement>();
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
table.setName("table");
MetadataColumn id = ConnectionFactory.eINSTANCE.createMetadataColumn();
id.setName("id");
id.setLabel("id");
id.setTable(table);
MetadataColumn name = ConnectionFactory.eINSTANCE.createMetadataColumn();
name.setName("name");
name.setLabel("name");
name.setTable(table);
MetadataColumn email = ConnectionFactory.eINSTANCE.createMetadataColumn();
email.setName("email");
email.setLabel("email");
email.setTable(table);
analysisElementList.add(id);
analysisElementList.add(name);
analysisElementList.add(email);
FileCSVReader fileCSVReader = new FileCSVReader(file, delimitedFileconnection, analysisElementList);
String fileContent = "";
int i = 0;
while (fileCSVReader.hasNext()) {
i++;
Record record = fileCSVReader.next();
List<Attribute> attributes = record.getAttributes();
fileContent += i + ":";
for (Attribute attribute : attributes) {
fileContent += "[" + attribute.getLabel() + "," + attribute.getValue() + "]";
}
}
fileCSVReader.close();
Assert.assertEquals("1:[id,1][name,tom][email,a@b.cn]2:[id,2][name,jerry][email,x@b.cn]3:[id,3][name,bob][email,top@b.cn]", fileContent);
}
// delete the temp file
if (file.exists()) {
file.delete();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations