Search in sources :

Example 6 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.

the class RepositoryTypeProcessor method selectRepositoryNode.

@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    final String repositoryType = getRepositoryType();
    if (node == null) {
        return false;
    }
    if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    // for sub folders
    if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
        return false;
    }
    // for Db Connections
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    // }
    IRepositoryViewObject object = node.getObject();
    if (object == null || object.getProperty().getItem() == null) {
        return false;
    }
    if (object instanceof MetadataTable) {
        return false;
    }
    Item item = object.getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    if (item instanceof ConnectionItem) {
        ConnectionItem connectionItem = (ConnectionItem) item;
        Connection connection = connectionItem.getConnection();
        // tAdvancedFileOutputXML
        if (repositoryType != null && repositoryType.equals(ERepositoryCategoryType.XMLOUTPUT.getName())) {
            if (connection instanceof XmlFileConnection && ((XmlFileConnection) connection).isInputModel()) {
                return false;
            }
        }
        if (repositoryType.startsWith(ERepositoryCategoryType.DATABASE.getName())) {
            //$NON-NLS-1$
            String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
            if (repositoryType.contains(":")) {
                // database //$NON-NLS-1$
                // is
                // specified
                // //$NON-NLS-1$
                //$NON-NLS-1$
                String neededDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
                if (hidenTypeSelection) {
                    return true;
                }
                if (!MetadataTalendType.sameDBProductType(neededDbType, currentDbType)) {
                    return false;
                }
            }
        }
    }
    if (repositoryType.startsWith(ERepositoryCategoryType.HEADERFOOTER.getName())) {
        if (item instanceof HeaderFooterConnectionItem) {
            HeaderFooterConnectionItem connectionItem = (HeaderFooterConnectionItem) item;
            HeaderFooterConnection connection = (HeaderFooterConnection) connectionItem.getConnection();
            boolean isHeader = connection.isIsHeader();
            if ((isHeader && isHeaderButton) || (!isHeader && !isHeaderButton)) {
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) FolderItem(org.talend.core.model.properties.FolderItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) FolderItem(org.talend.core.model.properties.FolderItem) HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection)

Example 7 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.

the class ValidationRuleTypeProcessor method selectRepositoryNode.

@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    if (node.getContentType() == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    ProjectManager pManager = ProjectManager.getInstance();
    if (!pManager.isInCurrentMainProject(node)) {
        if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
            return false;
        }
        if (node.getType() == ENodeType.SYSTEM_FOLDER) {
            return true;
        }
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    if (node.getObject() == null || node.getObject().getProperty().getItem() == null) {
        return false;
    }
    if (node.getObject() instanceof MetadataTable) {
        return false;
    }
    Item item = node.getObject().getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    if (node.getObjectType() == getType()) {
        return true;
    }
    return false;
}
Also used : FolderItem(org.talend.core.model.properties.FolderItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) MetadataTable(org.talend.core.model.metadata.MetadataTable) ProjectManager(org.talend.repository.ProjectManager)

Example 8 with FolderItem

use of org.talend.core.model.properties.FolderItem in project tdi-studio-se by Talend.

the class TosTokenCollector method collectJobDetails.

/**
     * DOC nrousseau Comment method "collectJobDetails".
     * 
     * @param all
     * @param jobDetails
     * @throws JSONException
     */
private void collectJobDetails(List<IRepositoryViewObject> allRvo, JSONObject jobDetails) throws JSONException {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IEditorReference[] reference = new IEditorReference[0];
    if (ww != null) {
        IWorkbenchPage page = ww.getActivePage();
        reference = page.getEditorReferences();
    }
    List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
    Set<String> idsOpened = new HashSet<String>();
    for (IProcess2 process : processes) {
        idsOpened.add(process.getId());
    }
    JSONArray components = new JSONArray();
    int contextVarsNum = 0;
    int nbComponentsUsed = 0;
    for (IRepositoryViewObject rvo : allRvo) {
        Item item = rvo.getProperty().getItem();
        if (item instanceof ProcessItem) {
            ProcessType processType = ((ProcessItem) item).getProcess();
            for (NodeType node : (List<NodeType>) processType.getNode()) {
                JSONObject component_names = null;
                String componentName = node.getComponentName();
                int nbComp = 0;
                for (int i = 0; i < components.length(); i++) {
                    JSONObject temp = components.getJSONObject(i);
                    if (temp.get("component_name").equals(componentName)) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        nbComp = temp.getInt("count");
                        component_names = temp;
                        break;
                    }
                }
                if (component_names == null) {
                    component_names = new JSONObject();
                    components.put(component_names);
                }
                component_names.put("component_name", componentName);
                component_names.put("count", nbComp + 1);
                nbComponentsUsed++;
            }
            // context variable per job
            EList contexts = processType.getContext();
            if (contexts.size() > 0) {
                ContextType contextType = (ContextType) contexts.get(0);
                contextVarsNum += contextType.getContextParameter().size();
            }
        }
        if (factory.getStatus(item) != ERepositoryStatus.LOCK_BY_USER && !idsOpened.contains(item.getProperty().getId())) {
            // job is not locked and not opened by editor, so we can unload.
            if (item.getParent() instanceof FolderItem) {
                ((FolderItem) item.getParent()).getChildren().remove(item);
                item.setParent(null);
            }
            item.eResource().unload();
        }
    }
    jobDetails.put("components", components);
    jobDetails.put("nb.contextVars", contextVarsNum);
    jobDetails.put("nb.components", nbComponentsUsed);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) JSONArray(us.monoid.json.JSONArray) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IEditorReference(org.eclipse.ui.IEditorReference) EList(org.eclipse.emf.common.util.EList) FolderItem(org.talend.core.model.properties.FolderItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JSONObject(us.monoid.json.JSONObject) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) HashSet(java.util.HashSet)

Aggregations

FolderItem (org.talend.core.model.properties.FolderItem)8 Item (org.talend.core.model.properties.Item)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 MetadataTable (org.talend.core.model.metadata.MetadataTable)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 EList (org.eclipse.emf.common.util.EList)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1