use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class JobScriptsExportWizardPage method getProcessItem.
protected ProcessItem getProcessItem() {
if ((processItem == null) && (nodes != null) && (nodes.length >= 1)) {
IRepositoryViewObject repositoryObject = nodes[0].getObject();
// add for bug TDI-20132
List<IRepositoryNode> nodesChildren = nodes[0].getChildren();
IRepositoryViewObject childObject = null;
if ((nodesChildren != null) && (nodesChildren.size() >= 1)) {
childObject = nodesChildren.get(0).getObject();
}
if (repositoryObject == null && childObject != null && childObject.getProperty().getItem() instanceof ProcessItem) {
processItem = (ProcessItem) childObject.getProperty().getItem();
}
if (repositoryObject != null && repositoryObject.getProperty().getItem() instanceof ProcessItem) {
processItem = (ProcessItem) repositoryObject.getProperty().getItem();
} else if (repositoryObject != null && repositoryObject.getProperty().getItem() instanceof FolderItem) {
processItem = getProcessItemIfSelectFolder(repositoryObject);
}
}
return processItem;
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method getJobRepositoryNode.
private static IRepositoryNode getJobRepositoryNode(String jobId, ERepositoryObjectType type) throws PersistenceException {
List<IRepositoryViewObject> list = new ArrayList<>();
List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
for (Project p : projects) {
list.addAll(ProxyRepositoryFactory.getInstance().getAll(p, type));
}
list.addAll(ProxyRepositoryFactory.getInstance().getAll(type));
for (IRepositoryViewObject job : list) {
if (job.getId().equals(jobId)) {
return new RepositoryNode(job, null, ENodeType.REPOSITORY_ELEMENT);
}
}
return null;
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSAction method exportAllReferenceJobs.
private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException {
for (NodeType cTalendJob : EmfModelUtils.getComponentsByName(routeProcess, "cTalendJob")) {
//$NON-NLS-1$
String jobId = null;
String jobVersion = null;
String jobContext = null;
for (Object o : cTalendJob.getElementParameter()) {
if (!(o instanceof ElementParameterType)) {
continue;
}
ElementParameterType ept = (ElementParameterType) o;
String eptName = ept.getName();
if ("FROM_EXTERNAL_JAR".equals(eptName) && "true".equals(ept.getValue())) {
//$NON-NLS-1$
break;
}
if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(eptName)) {
//$NON-NLS-1$
jobId = ept.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(eptName)) {
//$NON-NLS-1$
jobVersion = ept.getValue();
} else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(eptName)) {
//$NON-NLS-1$
jobContext = ept.getValue();
}
}
if (jobId == null || jobVersion == null) {
continue;
}
IRepositoryNode referencedJobNode;
try {
referencedJobNode = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) {
jobVersion = referencedJobNode.getObject().getVersion();
}
String jobName = referencedJobNode.getObject().getProperty().getDisplayName();
String jobBundleName = routeName + "_" + jobName;
String jobBundleSymbolicName = jobBundleName;
Project project = ProjectManager.getInstance().getCurrentProject();
if (project != null) {
String projectName = project.getLabel();
if (projectName != null && projectName.length() > 0) {
jobBundleSymbolicName = projectName.toLowerCase() + '.' + jobBundleSymbolicName;
}
}
File jobFile;
try {
jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, //$NON-NLS-1$
new File(getTempDir()));
} catch (IOException e) {
throw new InvocationTargetException(e);
}
String jobArtifactVersion = getArtifactVersion();
String jobBundleVersion = bundleVersion;
BundleModel jobModel = new BundleModel(getGroupId(), jobBundleName, jobArtifactVersion, jobFile);
if (featuresModel.addBundle(jobModel)) {
exportRouteUsedJobBundle(referencedJobNode, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobBundleVersion, getArtifactId(), version, jobContext);
}
}
}
Aggregations