use of org.talend.dataprofiler.core.ui.wizard.parserrule.ParserRuleToExcelEnum in project tdq-studio-se by Talend.
the class ExportFactory method getParserRuleEnumValues.
/**
* DOC klliu Comment method "getParserRuleEnumValues".
*
* @return
*/
private static ParserRuleToExcelEnum[] getParserRuleEnumValues() {
List<ParserRuleToExcelEnum> realValues = new ArrayList<ParserRuleToExcelEnum>();
ParserRuleToExcelEnum[] values = ParserRuleToExcelEnum.values();
for (ParserRuleToExcelEnum parserEnum : values) {
if (!(parserEnum.equals(ParserRuleToExcelEnum.Body) || parserEnum.equals(ParserRuleToExcelEnum.Language))) {
realValues.add(parserEnum);
}
}
return realValues.toArray(new ParserRuleToExcelEnum[realValues.size()]);
}
use of org.talend.dataprofiler.core.ui.wizard.parserrule.ParserRuleToExcelEnum in project tdq-studio-se by Talend.
the class ExportFactory method export.
public static void export(File exportFile, IFolder folder, ParserRule... parserRules) {
if (exportFile.isDirectory()) {
for (ParserRule pr : parserRules) {
// $NON-NLS-1$
File file = new File(exportFile, pr.getName() + ".csv");
export(file, folder, pr);
}
}
String fileExtName = getFileExtName(exportFile);
if (FileUtils.isCSV(fileExtName)) {
try {
CSVWriter out = FileUtils.createCSVWriter(exportFile, FileUtils.TEXT_QUAL, FileUtils.TEXT_QUAL);
List<TdExpression> expressions = parserRules[0].getExpression();
ParserRuleToExcelEnum[] values = getParserRuleEnumValues();
String[] temp = new String[values.length];
for (int i = 0; i < expressions.toArray().length + 1; i++) {
for (int j = 0; j < values.length; j++) {
if (i == 0) {
temp[j] = values[j].getLiteral();
} else {
Map<ParserRuleToExcelEnum, String> relatedValueFromParserRule = getRelatedValueFromParserRule(parserRules[0], folder, expressions.get(i - 1));
temp[j] = relatedValueFromParserRule.get(values[j]);
}
}
out.writeNext(temp);
}
out.flush();
out.close();
} catch (FileNotFoundException fe) {
MessageDialogWithToggle.openError(null, DefaultMessagesImpl.getString("ExportFactory.errorOne"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("ExportFactory.notFoundFile"));
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
use of org.talend.dataprofiler.core.ui.wizard.parserrule.ParserRuleToExcelEnum in project tdq-studio-se by Talend.
the class ExportFactory method getRelatedValueFromParserRule.
private static Map<ParserRuleToExcelEnum, String> getRelatedValueFromParserRule(ParserRule parserRule, IFolder folder, TdExpression tde) {
Map<ParserRuleToExcelEnum, String> idMap = new HashMap<ParserRuleToExcelEnum, String>();
if (folder != null) {
IFile file = ResourceFileMap.findCorrespondingFile(parserRule);
URI relativeURI = folder.getLocationURI().relativize(file.getParent().getLocationURI());
// get the basic information
idMap.put(ParserRuleToExcelEnum.Label, relpaceTempHasEscapeCharactor(parserRule.getName()));
idMap.put(ParserRuleToExcelEnum.Purpose, relpaceTempHasEscapeCharactor(MetadataHelper.getPurpose(parserRule)));
idMap.put(ParserRuleToExcelEnum.Description, relpaceTempHasEscapeCharactor(MetadataHelper.getDescription(parserRule)));
idMap.put(ParserRuleToExcelEnum.Author, relpaceTempHasEscapeCharactor(MetadataHelper.getAuthor(parserRule)));
idMap.put(ParserRuleToExcelEnum.RelativePath, relativeURI.toString());
idMap.put(ParserRuleToExcelEnum.Name, replaceQual(tde.getName()));
idMap.put(ParserRuleToExcelEnum.Type, replaceQual(tde.getLanguage()));
idMap.put(ParserRuleToExcelEnum.Value, replaceQual(tde.getBody()));
}
return idMap;
}
Aggregations