Search in sources :

Example 16 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class ExportItemWizardPage method collectNodes.

private void collectNodes(Map<String, Item> items, Object[] objects) {
    for (Object object : objects) {
        if (object instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) object;
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            if (repositoryObject != null) {
                if (repositoryObject.getRepositoryObjectType().isResourceItem()) {
                    Item item = repositoryObject.getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            } else {
                if (repositoryNode.getParent() != null && repositoryNode.getParent().getObject() != null) {
                    Item item = repositoryNode.getParent().getObject().getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            }
            if (filteredCheckboxTree != null && !isHadoopClusterNode(repositoryNode)) {
                IContentProvider contentProvider = filteredCheckboxTree.getViewer().getContentProvider();
                if (contentProvider instanceof ITreeContentProvider) {
                    // only check childrens of allowed items in this viewer
                    if (selectRepositoryNode(getItemsTreeViewer(), repositoryNode)) {
                        Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
                        List<Object> childrenNodes = getUnTestCaseChildren(children);
                        collectNodes(items, childrenNodes.toArray());
                    }
                }
            }
        } else {
            for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                Property property = nodeHandler.getProperty(object);
                if (property != null) {
                    items.put(property.getId(), property.getItem());
                }
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property)

Example 17 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class MetadataColumnComparator method createNewRepositoryNode.

/**
     * dev Comment method "createNewRepositoryNode".
     * 
     * @param node
     * @param parameters
     * @param connection
     * @param iMetadataConnection
     * @return
     */
@SuppressWarnings("unchecked")
private RepositoryNode createNewRepositoryNode(RepositoryNode node, ConnectionParameters parameters, DatabaseConnection connection, IMetadataConnection iMetadataConnection) {
    ManagerConnection managerConnection = new ManagerConnection();
    boolean status = managerConnection.check(iMetadataConnection);
    connection.setDivergency(!status);
    ConnectionHelper.getTables(connection).clear();
    if (status) {
    // try {
    // List<MetadataTable> tablesFromDB = ExtractMetaDataFromDataBase.returnMetaTablesFormConnection(
    // iMetadataConnection, 500);
    // ExtractMetaDataUtils.getInstance().setReconnect(false);
    // for (MetadataTable table : tablesFromDB) {
    // List<MetadataColumn> columnsFromDB = new ArrayList<MetadataColumn>();
    // columnsFromDB.addAll(ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection,
    // table.getSourceName()));
    // table.getColumns().clear();
    // for (MetadataColumn column : columnsFromDB) {
    // column.setLabel(""); //$NON-NLS-1$
    // table.getColumns().add(column);
    // }
    // table.setLabel(""); //$NON-NLS-1$
    // ConnectionHelper.getTables(connection).add(table);
    // }
    // ExtractMetaDataUtils.getInstance().setReconnect(true);
    // } catch (Exception e) {
    // if (parameters != null) {
    // parameters.setConnectionComment(e.getMessage());
    // }
    // return null;
    // }
    } else {
        if (parameters != null) {
            parameters.setConnectionComment(managerConnection.getMessageException() == null ? "" : //$NON-NLS-1$
            managerConnection.getMessageException());
        }
    }
    DatabaseConnectionItem item = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    connectionProperty.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
    connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
    //$NON-NLS-1$
    connectionProperty.setStatusCode("");
    item.setProperty(connectionProperty);
    // TDI-18665
    updatePackage(iMetadataConnection);
    DatabaseConnection dbConn = (DatabaseConnection) iMetadataConnection.getCurrentConnection();
    item.setConnection(dbConn);
    RepositoryObject object = new RepositoryObject(connectionProperty);
    //$NON-NLS-1$
    object.setLabel("");
    ItemState state = PropertiesFactory.eINSTANCE.createItemState();
    state.setDeleted(false);
    item.setState(state);
    if (node == null) {
        node = new RepositoryNode(null, null, ENodeType.SYSTEM_FOLDER);
    }
    RepositoryNode newNode = new RepositoryNode(object, node, ENodeType.SYSTEM_FOLDER);
    return newNode;
}
Also used : ManagerConnection(org.talend.metadata.managment.repository.ManagerConnection) SqlBuilderRepositoryObject(org.talend.sqlbuilder.dbstructure.SqlBuilderRepositoryObject) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) MetadataColumnRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataColumnRepositoryObject) ItemState(org.talend.core.model.properties.ItemState) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 18 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method researchMaxVersion.

private void researchMaxVersion() {
    String version = statusCombo.getText();
    if ("".equals(version.trim())) {
        //$NON-NLS-1$
        version = VersionUtils.DEFAULT_VERSION;
    }
    for (RepositoryObject object : checkedObjects) {
    // if (VersionUtils.compareTo(version, object.getOldVersion()) < 0) {
    // version = object.getOldVersion();
    // }
    }
    statusCombo.setText(version);
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject)

Example 19 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class FixUnevenItemContextParametersMigrationTaskTest method testAfter.

@After
public void testAfter() throws PersistenceException, BusinessException {
    RepositoryObject objToDelete = new RepositoryObject(testItem.getProperty());
    ProxyRepositoryFactory.getInstance().deleteObjectPhysical(objToDelete);
    testItem = null;
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) After(org.junit.After)

Example 20 with RepositoryObject

use of org.talend.core.model.repository.RepositoryObject in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method processItems.

private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode((RepositoryNode) node)) {
                // must be item
                RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
                object.setRepositoryNode(node);
                // ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Aggregations

RepositoryObject (org.talend.core.model.repository.RepositoryObject)22 RepositoryNode (org.talend.repository.model.RepositoryNode)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 Property (org.talend.core.model.properties.Property)6 TableItem (org.eclipse.swt.widgets.TableItem)5 IPath (org.eclipse.core.runtime.IPath)4 IEditorPart (org.eclipse.ui.IEditorPart)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)4 ArrayList (java.util.ArrayList)3 ISelection (org.eclipse.jface.viewers.ISelection)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 GridData (org.eclipse.swt.layout.GridData)3 Item (org.talend.core.model.properties.Item)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 IUIRefresher (org.talend.core.services.IUIRefresher)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2