use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.
the class AElementPersistanceRealTest method testCreateItemAnalysis.
/**
* Test method for
* {@link org.talend.dq.writer.AElementPersistance#createItem(orgomg.cwm.objectmodel.core.ModelElement)}.
*/
@Test
public void testCreateItemAnalysis() {
AnalysisWriter createAnalysisWrite = ElementWriterFactory.getInstance().createAnalysisWrite();
// test normal name
// $NON-NLS-1$
String anaName = "ana1";
// $NON-NLS-1$
String exceptedFileName = anaName + "_0.1.ana";
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
createAnalysis.setName(anaName);
Item createItem = createAnalysisWrite.createItem(createAnalysis);
assertTrue(createItem instanceof TDQAnalysisItem);
TDQAnalysisItem analysisItem = (TDQAnalysisItem) createItem;
assertTrue(analysisItem.getFilename().equals(exceptedFileName));
// test special name
// $NON-NLS-1$
String anaNameWithSpecialChar = "ana1~!`";
// $NON-NLS-1$
String exceptedFileName2 = "ana1____0.1.ana";
Analysis createAnalysis2 = AnalysisFactory.eINSTANCE.createAnalysis();
createAnalysis2.setName(anaNameWithSpecialChar);
Item createItem2 = createAnalysisWrite.createItem(createAnalysis2);
assertTrue(createItem2 instanceof TDQAnalysisItem);
TDQAnalysisItem analysisItem2 = (TDQAnalysisItem) createItem2;
assertTrue(analysisItem2.getFilename().equals(exceptedFileName2));
}
use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.
the class AnalysisBuilder method saveAnalysis.
/**
* Method "saveAnalysis". This method should be called when the creation of the analysis definition (analysis
* context + parameters) is created. It is not safe to use it for saving the analysis after the evaluation of the
* analysis result. The domain should be saved before calling this method.
*
* @param folder the folder where the analysis is saved.
* @return true if saved without problem
*/
public boolean saveAnalysis(IFolder folder) {
assert analysis != null;
AnalysisWriter writer = ElementWriterFactory.getInstance().createAnalysisWrite();
String filename = DqRepositoryViewService.createFilename(this.analysis.getName(), FactoriesUtil.ANA);
IFile file = folder.getFile(filename);
ReturnCode saved = writer.create(analysis, folder);
if (saved.isOk()) {
if (log.isDebugEnabled()) {
// $NON-NLS-1$
log.debug("Saved in " + file.getFullPath());
}
}
return saved.isOk();
}
use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.
the class AnalysisExecutorSelector method executeAnalysis.
public static ReturnCode executeAnalysis(final TDQAnalysisItem analysisItem, final IProgressMonitor monitor) {
IAnalysisExecutor analysisExecutor = getAnalysisExecutor(analysisItem.getAnalysis());
if (analysisExecutor != null) {
// MOD xqliu 2009-02-09 bug 6237
analysisExecutor.setMonitor(monitor);
ReturnCode execute = analysisExecutor.execute(analysisItem.getAnalysis());
// save analysis.
if (Platform.isRunning()) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (monitor != null && !monitor.isCanceled()) {
// $NON-NLS-1$
monitor.subTask(Messages.getString("AnalysisExecutorSelector.SavingAnalysisTask"));
AnalysisWriter writer = ElementWriterFactory.getInstance().createAnalysisWrite();
writer.save(analysisItem, Boolean.FALSE);
monitor.worked(10);
}
}
});
}
return execute;
}
// else
return new ReturnCode(Messages.getString("AnalysisExecutorSelector.NotFindHowExecute", analysisItem.getAnalysis().getName()), // $NON-NLS-1$
false);
}
use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.
the class AbstractAnalysisWizard method createAndSaveCWMFile.
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
Analysis analysis = (Analysis) cwmElement;
IFolder folder = parameter.getFolderProvider().getFolderResource();
AnalysisWriter analysisWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
return analysisWriter.create(analysis, folder);
}
use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.
the class IndicatorSettingsPage method modifyAndSaveLimit.
/**
* DOC zshen Comment method "modifyAndSaveLimit".
*
* @param anaNode
* @param isLowCase
*/
private void modifyAndSaveLimit(AnalysisRepNode anaNode, boolean isLowCase) {
Analysis analysis = anaNode.getAnalysis();
for (Indicator indicator : analysis.getResults().getIndicators()) {
if (isLowCase) {
modifyLowFre(indicator);
} else {
// too many frequency type
modifyFre(indicator);
}
}
AnalysisWriter anaWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
anaWriter.save(anaNode.getObject().getProperty().getItem(), false);
((TDQAnalysisItem) anaNode.getObject().getProperty().getItem()).setAnalysis(analysis);
// Resource resource = analysis.eResource();
// EMFUtil.saveSingleResource(resource);
}
Aggregations