Search in sources :

Example 11 with ItemRecord

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

the class ImportAndExportUtils method iterateUncheckClientDependency.

/**
 * when uncheck an item,should uncheck related client depenedences.
 *
 * @param dependencyClients
 */
public static void iterateUncheckClientDependency(List<ModelElement> dependencyClients, CheckboxTreeViewer repositoryTree) {
    for (ModelElement dependency : dependencyClients) {
        List<ModelElement> iterdependencyClients = EObjectHelper.getDependencyClients(dependency);
        if (!iterdependencyClients.isEmpty()) {
            iterateUncheckClientDependency(iterdependencyClients, repositoryTree);
        }
        URI uri = EObjectHelper.getURI(dependency);
        if (uri != null) {
            String uriString = WorkspaceUtils.toFile(uri);
            File depFile = new File(uriString);
            ItemRecord findRecord = ItemRecord.findRecord(depFile);
            if (findRecord != null) {
                repositoryTree.setChecked(findRecord, false);
            }
        }
    }
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) URI(org.eclipse.emf.common.util.URI) File(java.io.File)

Example 12 with ItemRecord

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

the class ExportForExchangeWizard method buildItemRecordList.

/**
 * build the export record map.
 *
 * @param records key = export zip file name; value = record list which should be add to the zip file
 * @return
 */
protected Map<String, ItemRecord[]> buildItemRecordList(ItemRecord[] records) {
    Map<String, ItemRecord[]> map = new HashMap<String, ItemRecord[]>();
    for (ItemRecord record : records) {
        ModelElement element = record.getElement();
        if (element != null) {
            // $NON-NLS-1$
            String zipFileName = element.getName() + ".zip";
            List<ItemRecord> list = new ArrayList<ItemRecord>();
            list.add(record);
            map.put(zipFileName, list.toArray(new ItemRecord[list.size()]));
        }
    }
    return map;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) HashMap(java.util.HashMap) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList)

Example 13 with ItemRecord

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

the class ExportUdiForExchangeWizard method buildItemRecordList.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.imex.ExportForExchangeWizard#buildItemRecordList(org.talend.dataprofiler.core
     * .ui.imex.model.ItemRecord[])
     */
@Override
protected Map<String, ItemRecord[]> buildItemRecordList(ItemRecord[] records) {
    Map<String, ItemRecord[]> map = new HashMap<String, ItemRecord[]>();
    for (ItemRecord record : records) {
        ModelElement element = record.getElement();
        if (element != null) {
            // $NON-NLS-1$
            String zipFileName = element.getName() + ".zip";
            List<ItemRecord> list = new ArrayList<ItemRecord>();
            list.add(record);
            list.addAll(getDependencyRecords(record));
            map.put(zipFileName, list.toArray(new ItemRecord[list.size()]));
        }
    }
    return map;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) HashMap(java.util.HashMap) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList)

Example 14 with ItemRecord

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

the class ExportUdiForExchangeWizard method getDependencyRecords.

/**
 * get the dependency ItemRecord for UDI.
 *
 * @param record UDI ItemRecord
 * @param records jar files ItemRecord which dependencied by UDI
 * @return
 */
private List<ItemRecord> getDependencyRecords(ItemRecord record) {
    List<ItemRecord> list = new ArrayList<ItemRecord>();
    List<File> udiJarfiles = new ArrayList<File>();
    TaggedValue tv = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, record.getElement().getTaggedValue());
    if (tv != null) {
        for (IFile udiJarFile : UDIUtils.getLibJarFileList()) {
            for (String jarName : tv.getValue().split("\\|\\|")) {
                // $NON-NLS-1$
                if (udiJarFile.getName().equals(jarName)) {
                    udiJarfiles.add(udiJarFile.getLocation().toFile());
                    break;
                }
            }
        }
    }
    for (File jarFile : udiJarfiles) {
        list.add(new ItemRecord(jarFile));
    }
    return list;
}
Also used : IFile(org.eclipse.core.resources.IFile) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 15 with ItemRecord

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

the class ExportWizardPage method createRepositoryTree.

/**
 * DOC bZhou Comment method "createRepositoryTree".
 *
 * @param top
 */
protected void createRepositoryTree(Composite top) {
    Composite treeComposite = new Composite(top, SWT.NONE);
    treeComposite.setLayout(new GridLayout(2, false));
    treeComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTree = new ContainerCheckedTreeViewer(treeComposite);
    repositoryTree.setContentProvider(new FileTreeContentProvider());
    repositoryTree.setLabelProvider(new FileTreeLabelProvider());
    repositoryTree.setInput(writer.computeInput(specifiedPath));
    repositoryTree.expandAll();
    repositoryTree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    // ADD msjian TDQ-14573: automatically checked the initial selected items.
    if (intCheckedElements != null) {
        List<ItemRecord> selectedItemRecords = new ArrayList<ItemRecord>();
        for (Object intCheckedElement : intCheckedElements) {
            getFileFromNode(selectedItemRecords, (IRepositoryNode) intCheckedElement);
        }
        repositoryTree.setCheckedElements(selectedItemRecords.toArray());
    }
    // show the same order with repository tree
    repositoryTree.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer iviewer, Object o1, Object o2) {
            DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((ItemRecord) o1).getElement());
            DQRepositoryNode recursiveFind2 = RepositoryNodeHelper.recursiveFind(((ItemRecord) o2).getElement());
            return new RepositoryNodeComparator().compare(recursiveFind, recursiveFind2);
        }
    });
    // TDQ-14573~
    createUtilityButtons(treeComposite);
}
Also used : RepositoryNodeComparator(org.talend.dq.helper.RepositoryNodeComparator) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ArrayList(java.util.ArrayList) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) GridData(org.eclipse.swt.layout.GridData) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)

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