use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class ExportUDIWizard method performFinish.
@Override
public boolean performFinish() {
String targetFile = page.getTargetFile();
Object[] elements = page.getSelectedTree().getCheckedElements();
List<IndicatorDefinition> seletedIndicators = new ArrayList<IndicatorDefinition>();
for (Object element : elements) {
if (element instanceof IFile) {
IFile file = (IFile) element;
if (FactoriesUtil.DEFINITION.equalsIgnoreCase(file.getFileExtension())) {
seletedIndicators.add(IndicatorResourceFileHelper.getInstance().findIndDefinition(file));
}
} else if (element instanceof SysIndicatorDefinitionRepNode && !((SysIndicatorDefinitionRepNode) element).isSystemIndicator()) {
SysIndicatorDefinitionRepNode udiElement = (SysIndicatorDefinitionRepNode) element;
seletedIndicators.add(udiElement.getIndicatorDefinition());
}
}
if ("".equals(targetFile)) {
// $NON-NLS-1$
MessageDialog.openError(getShell(), DefaultMessagesImpl.getString("ExportUDIWizard.Error"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("ExportUDIWizard.SpecifyValidResource"));
return false;
} else {
File resource = new File(targetFile);
if (isForExchange) {
ExportFactory.export(resource, folder, seletedIndicators.toArray(new IndicatorDefinition[seletedIndicators.size()]));
for (Iterator<IndicatorDefinition> iterator = seletedIndicators.iterator(); iterator.hasNext(); ) {
IndicatorDefinition id = iterator.next();
// $NON-NLS-1$
File idFile = new File(resource, id.getName() + ".csv");
if (idFile.isFile() && idFile.exists()) {
try {
List<File> udiAndJarfiles = new ArrayList<File>();
udiAndJarfiles.add(idFile);
// MOD by zshen for bug 18724 2011.03.01
TaggedValue tv = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, id.getTaggedValue());
if (tv != null) {
for (IFile udiJarFile : UDIUtils.getLibJarFileList()) {
for (String jarName : tv.getValue().split("\\|\\|")) {
// $NON-NLS-1$
if (udiJarFile.getName().equals(jarName)) {
udiAndJarfiles.add(udiJarFile.getLocation().toFile());
break;
}
}
}
}
// ~
// $NON-NLS-1$
FilesUtils.zips(udiAndJarfiles.toArray(new File[udiAndJarfiles.size()]), idFile.getPath() + ".zip");
idFile.delete();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
return true;
} else {
boolean isContinue = true;
if (resource.exists()) {
isContinue = MessageDialogWithToggle.openConfirm(null, // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.waring"), // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.fileAlreadyExist"));
}
if (isContinue) {
ExportFactory.export(resource, folder, seletedIndicators.toArray(new IndicatorDefinition[seletedIndicators.size()]));
return true;
}
return false;
}
}
}
Aggregations