Search in sources :

Example 1 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class FileTreeLabelProviderTest method testGetImageObjectCase2.

/**
 * Test method for {@link org.talend.dataprofiler.core.ui.imex.FileTreeLabelProvider#getImage(java.lang.Object)}.
 * case 2 :element is parser rule
 */
@Test
public void testGetImageObjectCase2() {
    File file = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(createTDQParserRuleItem.getDqrule().eResource().getURI().toPlatformString(false))).getLocation().toFile();
    ItemRecord itemRecord = new ItemRecord(file);
    FileTreeLabelProvider fileTreeLabelProvider = new FileTreeLabelProvider();
    Image image = fileTreeLabelProvider.getImage(itemRecord);
    Assert.assertEquals(ImageLib.getImage(ImageLib.DQ_RULE), image);
}
Also used : Path(org.eclipse.core.runtime.Path) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) Image(org.eclipse.swt.graphics.Image) File(java.io.File) Test(org.junit.Test)

Example 2 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ImportWizard method performFinish.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    // TDQ-10715: only close the DQ editors before import items except the sql editor and text editor.
    // TDQ-13856: when click cancel, do NOT close any editors.
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart[] editors = activePage.getEditors();
    for (IEditorPart editor : editors) {
        if (editor instanceof CommonFormEditor) {
            boolean isSaved = activePage.closeEditor(editor, true);
            if (!isSaved) {
                // $NON-NLS-1$
                MessageUI.openWarning(DefaultMessagesImpl.getString("ImportItemAction.closeEditors"));
                return true;
            }
        }
    }
    // ADD xqliu TDQ-4284 2011-12-26
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return true;
    }
    // ~ TDQ-4284
    final ItemRecord[] records = importPage.getElements();
    final IImportWriter writer = importPage.getWriter();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            // $NON-NLS-1$
            monitor.beginTask("Import Item", records.length);
            writer.write(records, monitor);
            monitor.done();
        }
    };
    try {
        ProgressUI.popProgressDialog(op);
    } catch (Exception e) {
        log.error(e, e);
    }
    CorePlugin.getDefault().refreshWorkSpace();
    CorePlugin.getDefault().refreshDQView();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) IImportWriter(org.talend.dataprofiler.core.ui.imex.model.IImportWriter) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) InvocationTargetException(java.lang.reflect.InvocationTargetException) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 3 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ImportWizard method performCancel.

@Override
public boolean performCancel() {
    final ItemRecord[] records = importPage.getElements();
    if (records.length > 0) {
        final IImportWriter writer = importPage.getWriter();
        try {
            writer.finish(records, null);
            writer.postFinish();
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    return super.performCancel();
}
Also used : ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) IImportWriter(org.talend.dataprofiler.core.ui.imex.model.IImportWriter) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ImportWizardPage method updateErrorList.

/**
 * DOC bZhou Comment method "updateErrorList".
 *
 * @param records
 */
public void updateErrorList(ItemRecord[] records) {
    errors.clear();
    for (ItemRecord record : records) {
        errors.addAll(record.getErrors());
    }
    errorsList.setInput(errors);
    errorsList.refresh();
}
Also used : ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord)

Example 5 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ImportWizardPage method checkforErrors.

/**
 * check that directory exist and issue an error message if not. <br>
 * check that the folder is a data quality repository or issue an error.<br>
 * check that anything is check in the tree or issue an error.<br>
 */
protected void checkforErrors() {
    List<String> dErrors = new ArrayList<String>();
    if (repositoryTree.getTree().getItems().length == 0) {
        // $NON-NLS-1$
        dErrors.add(Messages.getString("ImportWizardPage.0"));
    }
    if (repositoryTree.getCheckedElements().length == 0) {
        // $NON-NLS-1$
        dErrors.add(Messages.getString("ImportWizardPage.1"));
    }
    dErrors.addAll(writer.check());
    ItemRecord[] elements = getElements();
    for (ItemRecord record : elements) {
        dErrors.addAll(record.getErrors());
        for (File depFile : record.getDependencySet()) {
            ItemRecord findRecord = ItemRecord.findRecord(depFile);
            if (findRecord == null || !repositoryTree.getChecked(findRecord)) {
                // TDQ-12410: if the dependency comes from reference project, we ingore it.
                if (!DqFileUtils.isFileUnderBasePath(depFile, writer.getBasePath())) {
                    continue;
                }
                ModelElement element = ItemRecord.getElement(depFile);
                // Indicator, don't add it into errors even if it is not exist
                if (element instanceof IndicatorDefinition) {
                    String uuid = ResourceHelper.getUUID(element);
                    if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
                        continue;
                    }
                }
                // MOD qiongli 2012-12-13 TDQ-5356 use itself file name for jrxml
                boolean isJrxmlDepFile = depFile.getName().endsWith(FactoriesUtil.JRXML);
                // MOD msjian TDQ-5909: modify to displayName
                String dptLabel = element != null && !isJrxmlDepFile && PropertyHelper.getProperty(element) != null ? PropertyHelper.getProperty(element).getDisplayName() : depFile.getName();
                // TDQ-5909~
                // $NON-NLS-1$ //$NON-NLS-2$
                dErrors.add("\"" + record.getName() + "\" miss dependency :" + dptLabel);
            }
        }
    }
    if (!dErrors.isEmpty()) {
        setErrorMessage(dErrors.get(0));
    } else {
        setErrorMessage(null);
    }
    updatePageStatus();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ArrayList(java.util.ArrayList) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Aggregations

ItemRecord (org.talend.dataprofiler.core.ui.imex.model.ItemRecord)26 File (java.io.File)15 ArrayList (java.util.ArrayList)14 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)10 IFile (org.eclipse.core.resources.IFile)6 Path (org.eclipse.core.runtime.Path)6 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)5 List (java.util.List)4 Image (org.eclipse.swt.graphics.Image)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IPath (org.eclipse.core.runtime.IPath)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Test (org.junit.Test)3 Property (org.talend.core.model.properties.Property)3 HashMap (java.util.HashMap)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2