Search in sources :

Example 91 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tesb-studio-se by Talend.

the class KarafJavaScriptForESBWithMavenManager method analysisMavenModule.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void analysisMavenModule(Item item) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
        ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
        if (camelService.isInstanceofCamelRoutes(item)) {
            ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            List<String> mavenModules = getMavenModules();
            mavenModules.clear();
            talendJobsMap.clear();
            EList nodes = ((CamelProcessItem) item).getProcess().getNode();
            for (NodeType node : (List<NodeType>) nodes) {
                if ("cTalendJob".equals(node.getComponentName())) {
                    // $NON-NLS-1$
                    String talendJobId = null;
                    String talendJobVersion = null;
                    String talendJobContextGroup = null;
                    EList elementParameters = node.getElementParameter();
                    for (ElementParameterType paramType : (List<ElementParameterType>) elementParameters) {
                        if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(paramType.getName())) {
                            // $NON-NLS-1$
                            talendJobId = ProcessUtils.getPureItemId(paramType.getValue());
                        } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(paramType.getName())) {
                            // $NON-NLS-1$
                            talendJobVersion = paramType.getValue();
                        } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(paramType.getName())) {
                            // $NON-NLS-1$
                            talendJobContextGroup = paramType.getValue();
                        }
                        if (talendJobId != null && talendJobVersion != null && talendJobContextGroup != null) {
                            // found
                            break;
                        }
                    }
                    if (talendJobId != null) {
                        if (talendJobVersion == null) {
                            talendJobVersion = RelationshipItemBuilder.LATEST_VERSION;
                        }
                        if (talendJobContextGroup == null) {
                            talendJobContextGroup = IContext.DEFAULT;
                        }
                        IRepositoryViewObject foundObject = null;
                        try {
                            if (RelationshipItemBuilder.LATEST_VERSION.equals(talendJobVersion)) {
                                foundObject = factory.getLastVersion(talendJobId);
                            } else {
                                // find out the fixing version
                                List<IRepositoryViewObject> allVersionObjects = factory.getAllVersion(talendJobId);
                                if (allVersionObjects != null) {
                                    for (IRepositoryViewObject obj : allVersionObjects) {
                                        if (obj.getVersion().equals(talendJobVersion)) {
                                            foundObject = obj;
                                            break;
                                        }
                                    }
                                }
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                        if (foundObject != null) {
                            Property property = foundObject.getProperty();
                            if (property != null) {
                                talendJobsMap.put(talendJobId, foundObject);
                                talendJobContextGroupsMap.put(talendJobId, talendJobContextGroup);
                            // we do not export the referenced jobs literally,
                            // but get them for build from the Maven repository.
                            // Thus, we must not add module declarations for them.
                            // mavenModules.add(TALEND_JOBS_PATH + property.getLabel());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) List(java.util.List) EList(org.eclipse.emf.common.util.EList) Property(org.talend.core.model.properties.Property)

Example 92 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class JobResourceListener method removeLastServerInfo.

private void removeLastServerInfo(Item item) {
    Property property = item.getProperty();
    EMap additionalProperties = property.getAdditionalProperties();
    if (additionalProperties != null && additionalProperties.containsKey(RepositoryResourceUtil.PROP_LAST_SERVER_DEF)) {
        RepositoryResourceUtil.setLastServerDef(item, null);
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        try {
            item = RepositoryResourceUtil.assertItem(item);
            factory.save(item, true);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EMap(org.eclipse.emf.common.util.EMap) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property)

Aggregations

ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)92 PersistenceException (org.talend.commons.exception.PersistenceException)40 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)25 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)22 Project (org.talend.core.model.general.Project)20 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)17 EList (org.eclipse.emf.common.util.EList)15 IProject (org.eclipse.core.resources.IProject)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)14 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)12 User (org.talend.core.model.properties.User)11 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)11 Path (org.eclipse.core.runtime.Path)10 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)9 ArrayList (java.util.ArrayList)8 BusinessException (org.talend.commons.exception.BusinessException)8 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 EMFUtil (org.talend.commons.emf.EMFUtil)6